Share
Go down
Vinay
Posts : 2
Join date : 2011-11-23

Facing problem with element locator

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();
faramka
Professional
Professional
Posts : 143
Join date : 2011-09-15
Location : Poland

Re: Facing problem with element locator

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.
Vinay
Posts : 2
Join date : 2011-11-23

Re: Facing problem with element locator

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
ccnnll
Posts : 6
Join date : 2011-12-03

Timing?

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.)
qappbc
Amateur
Amateur
Posts : 38
Join date : 2011-10-13

Re: Facing problem with element locator

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);
avatar
satyamsing
Posts : 3
Join date : 2011-11-04

Element locator not found due to improper timing

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)
Sponsored content

Re: Facing problem with element locator

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