Search
 
 

Display results as :
 


Rechercher Advanced Search

Latest topics
» how to connect DB in selenium webriver
Fri Oct 06, 2017 4:09 pm by anbarasi

» How find any text in browser screen and click on it?
Thu Oct 05, 2017 2:02 pm by sandeepkommineni

» Selenium Webdriver
Tue Oct 03, 2017 1:35 pm by PiyushBiswas

» GRID setup tutorial.
Wed Sep 27, 2017 4:29 pm by johnyapp

» Drag & Drop Between Windows Using Selenium Driver
Wed Sep 27, 2017 2:10 pm by 26rondel

» Check if window is closed / verify input
Sat Sep 23, 2017 10:21 pm by brainstir

» How to work on pages with AJAX in selenium?
Mon Sep 18, 2017 6:08 pm by azharuddin

» pause test until user press a key like F2
Wed Aug 09, 2017 11:10 pm by djnforce

» Selecting the input for auto populating element
Sat Jul 29, 2017 7:53 pm by kdabbara

Navigation
 Portal
 Index
 Memberlist
 Profile
 FAQ
 Search

Why this is not working?

View previous topic View next topic Go down

Why this is not working?

Post by nz_hmz on Sat Jan 26, 2013 9:58 pm

Hi,

I am new to selenium automation and just started learning. I have developed a test case to search for yahoo mail and click search button then click on the yahoo mail link shown in the results page. I have used firbug to get the Xpath locations of the elements. Given below is the test case that i have written.

Code:

@Test
    public void SearchYahooTest()
    {
        Selenium selenium = new DefaultSelenium("localhost", 4444, "*googlechrome", "google url");
        selenium.start();
       
        selenium.open("google url");
        selenium.windowMaximize();
        selenium.windowFocus();
       
        for(int second = 0 ; ; second++){
            if(second > 60) fail("Reqquest timeout");
           
            if(selenium.isElementPresent("//input[@id='gbqfq']")){
                selenium.type("//input[@id='gbqfq']", "Yahoo Mail"); break;
           
            }else
            {try{Thread.sleep(1000);}catch(Exception e){ e.printStackTrace();}
            }
        }
       
        for(int second = 0 ; ; second++){
            if(second > 60){
                selenium.click("//button[@id='gbqfba']");
                break;
            }
           
            if(selenium.isElementPresent("//button[@id='gbqfb']")){
                selenium.click("//button[@id='gbqfb']"); break;
           
            }else
            {try{Thread.sleep(1000);}catch(Exception e){ e.printStackTrace();}
            }
        }
       
       
        for(int second = 0 ; ; second++){
            if(second > 60) fail("Reqquest timeout");
           
            if(selenium.isElementPresent("//html/body/div[6]/div[2]/div/div[7]/div/div[3]/div/div[2]/div/ol/li/div/h3/a/em")){
                selenium.click("//html/body/div[6]/div[2]/div/div[7]/div/div[3]/div/div[2]/div/ol/li/div/h3/a/em"); break;
           
            }else
            {try{Thread.sleep(1000);}catch(Exception e){ e.printStackTrace();}
            }
        }


the xpath of the yahoo mail results link i have got it using firebug. But when i run this test case it couldnt identify the search results element. So, I have used Selenium IDE and check it refers the element as selenium.click("css=em"); instead of the full Xpath that i have used. it works fine if i changed it that way.

I would like to know what is the difference. Why it fails, when i give the full xpath of the element?


Thanks in advance.

nz_hmz

Posts : 2
Join date : 2013-01-26

Back to top Go down

Re: Why this is not working?

Post by adityac on Mon Jan 28, 2013 3:59 pm

Test case failure might be because of loading time... so try to increase loading time because every time it may not tak same loading time

adityac
Professional
Professional

Posts : 101
Join date : 2013-01-17

Back to top Go down

Re: Why this is not working?

Post by nz_hmz on Tue Jan 29, 2013 9:44 am

adityac wrote:Test case failure might be because of loading time... so try to increase loading time because every time it may not tak same loading time

No it is not a timeout error that i am getting. with the full xpath slenium cannot locate the element. but selenium were able to locate it if I use "selenium.click("css=em");" instead full xpath.

nz_hmz

Posts : 2
Join date : 2013-01-26

Back to top Go down

Re: Why this is not working?

Post by adityac on Tue Jan 29, 2013 4:41 pm

how u r copying the xpath?? using firebug or firepath...

adityac
Professional
Professional

Posts : 101
Join date : 2013-01-17

Back to top Go down

Re: Why this is not working?

Post by Sponsored content


Sponsored content


Back to top Go down

View previous topic View next topic Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum