Search
 
 

Display results as :
 


Rechercher Advanced Search

Latest topics
» FlexMonkium Download Not available under Gorillalogic site
Thu Dec 08, 2016 5:40 pm by bhanu.praveen

» Selenium Script issue
Tue Dec 06, 2016 9:48 pm by njain213

» Difference between QTP, Selenium and Silk test
Tue Dec 06, 2016 7:58 pm by jessicacyrus1

» Where does selenium script pick browser from
Tue Dec 06, 2016 1:52 pm by janbaskt

» Safari throws an HTTP ERROR: 404
Tue Dec 06, 2016 1:51 pm by janbaskt

» Access Denied Error in Selenium RC
Tue Dec 06, 2016 1:51 pm by janbaskt

» Automating Flex application through selenium webdriver
Fri Dec 02, 2016 2:06 pm by abhinay.krs

» Starting with Selenium, what is Selenium?
Mon Nov 28, 2016 4:00 pm by Foma

» Getting started with Selenium
Mon Nov 28, 2016 3:23 pm by Rebbelx

Navigation
 Portal
 Index
 Memberlist
 Profile
 FAQ
 Search

Facing problem with element locator

View previous topic View next topic Go down

Facing problem with element locator

Post by Vinay on Wed Nov 23, 2011 4:44 pm

I am using Webdriver API and selenium-server-standalone-2.11.0 , junit,firefox to automate my proj on SAP Business Objects Platform.But i am facing errors in each and every line...I used Xpath even by add on(Firebug and Fire path).The code i have used is below and i have mentioned the errors.Could anyone please help in resolving these?

//Error: Username text edit element not found
driver
.findElement(By.id("usernameTextEdit")).clear();
//driver.findElement(By.xpath("//input[@id='usernameTextEdit']")).clear();
driver.findElement(By.id("usernameTextEdit")).sendKeys("Vinay");
//driver.findElement(By.xpath("//input[@id='usernameTextEdit']")).sendKeys("Vinay");

//Error: Password text edit element not found

driverfindElement(By.id("passwordTextEdit")).clear();

driver.findElement(By.id("passwordTextEdit")).sendKeys("Ab1234");
driver.findElement(By.cssSelector("input.logon_button.logon_button_hover")).click();
//driver.findElement(By.xpath("//input[@value='Log On']")).click();

//Window doesn't exist.
// ERROR: Caught exception [ERROR: Unsupported command [selectWindow]]
driver.findElement(By.linkText("Document List")).click();

//Navigate to Customer report and should open the report.
driver.findElement(By.id([size=9]"ListingURE_treeNode4_name")).click();

Vinay

Posts : 2
Join date : 2011-11-23

Back to top Go down

Re: Facing problem with element locator

Post by faramka on Wed Nov 23, 2011 8:13 pm

What is the content of this error and accurate id of elements?
I don't understand that: "Username text edit" is in error and id of an element is "usernameTextEdit". Is it just the example data for the post?

When you use xPath, Selenium is not showing any error?

If errors are displayed regardless of whether you use xpath or id, or something else, you have to see if selenium is on the correct and proper page, when referring to these elements.

faramka
Professional
Professional

Posts : 143
Join date : 2011-09-15
Location : Poland

Back to top Go down

Re: Facing problem with element locator

Post by Vinay on Wed Nov 23, 2011 9:00 pm

faramka wrote:What is the content of this error and accurate id of elements?
I don't understand that: "Username text edit" is in error and id of an element is "usernameTextEdit". Is it just the example data for the post?

When you use xPath, Selenium is not showing any error?

If errors are displayed regardless of whether you use xpath or id, or something else, you have to see if selenium is on the correct and proper page, when referring to these elements.



Thanks for your Reply!!!

Here are the details

"Username text edit" is not Error... It is Filed where selenium is throwing error.

Error message is:org.openqa.selenium.NoSuchElementException: Unable to locate element: {"method":"id","selector":"usernameTextEdit"}; duration or timeout: 30.06 seconds

Even I tried by using Xpath also same error is persisting

driver.findElement(By.xpath("//input[@id='usernameTextEdit']")).sendKeys("Vinay");

Error message is:org.openqa.selenium.NoSuchElementException: Unable to locate element: {"method":"id","selector":"usernameTextEdit"}; duration or timeout: 30.06 seconds

Vinay

Posts : 2
Join date : 2011-11-23

Back to top Go down

Timing?

Post by ccnnll on Sat Dec 03, 2011 3:43 am

Sometimes I've run into this as a timing issue. The script tries to find the element before it has finished rendering. Try adding a Thread.sleep(1000) before the FindElement to see if that helps. (Later you'd want to write something more like a global waitForElement function.)

ccnnll

Posts : 6
Join date : 2011-12-03

Back to top Go down

Re: Facing problem with element locator

Post by qappbc on Sat Dec 03, 2011 7:51 am

ccnnil is likely correct and when to call the 'wait' state. But I would recommend the WebDriver supplied 'implicit wait' - or if you know what to wait for, then use explicit wait.

"An implicit wait is to tell WebDriver to poll the DOM for a certain amount of time when trying to find an element or elements if they are not immediately available. The default setting is 0. Once set, the implicit wait is set for the life of the WebDriver object instance."

driver.manage().timeouts().implicitlyWait(3, TimeUnit.SECONDS);

qappbc
Amateur
Amateur

Posts : 38
Join date : 2011-10-13

Back to top Go down

Element locator not found due to improper timing

Post by satyamsing on Mon Jan 16, 2012 7:15 pm

When web elements are not found intermittently then the issue is most likely of timing. Depending on the loading constraints of the web page under test the WebElements are not found intermittently. A raw fix is to make the thread sleep for the time which you think is sufficient for the webelements to be available. An example would be:

WebDriver driver; (defined earlier)

driver.findElement(By.ID(ID_XXX)).click();
[size=9]
Thread.sleep(sleeptime);

Another method is to increase the wait using the following code:
WebDriver.Timeouts implicitlyWait(long time,
java.util.concurrent.TimeUnit unit)


For WebDriver and browser automation details visit:

http://seleniumhq.org/docs/

http://satyamsing.blogspot.com/2012/01/selenium-webdriver-interface.html

http://satyamsing.blogspot.com/2012/01/webdriver-better-tool.html

http://satyamsing.blogspot.com/2012/01/agile-identifying-when-and-what-to.html


Last edited by satyamsing on Mon Jan 16, 2012 7:18 pm; edited 1 time in total (Reason for editing : formatting)

satyamsing

Posts : 3
Join date : 2011-11-04

Back to top Go down

Re: Facing problem with element locator

Post by Sponsored content Today at 6:09 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