Search
 
 

Display results as :
 


Rechercher Advanced Search

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 Today at 7:26 am


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