WebDriver fails to read a jquery dialog widget

446 views
Skip to first unread message

cces...@gmail.com

unread,
Jan 23, 2013, 7:24:27 PM1/23/13
to seleniu...@googlegroups.com
Hello,

I have random error using the chrome driver. I open a dialog using the jquery ui/dialog widget and every now and then I get the following error

OpenQA.Selenium.ElementNotVisibleException : Element must be displayed to click (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 19 milliseconds
Build info: version: '2.26.0', revision: '18041', time: '2012-11-01 19:33:38'
System info: os.name: 'Windows Server 2008 R2', os.arch: 'x86', os.version: '6.1', java.version: '1.7.0_09'
Driver info: driver.version: RemoteWebDriver

The code to select the dialog is 

            var wait = new WebDriverWait(_driver, TimeSpan.FromSeconds(WaitInSeconds));
            wait.Until(ExpectedConditions.ElementIsVisible(By.CssSelector(selector)));

where selector is the  id something  like ("#dialog"). It works but every now and then fails.

any suggestions?

Mark Collin

unread,
Jan 24, 2013, 1:33:01 AM1/24/13
to seleniu...@googlegroups.com

Use an explicit wait to check for the existence of the element before you click on it.  It takes time for the browser to render the element when creating them with jQuery, sometimes Selenium is being quicker than your browser.

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/Wqd9Ui72ZxoJ.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

cces...@gmail.com

unread,
Jan 24, 2013, 10:54:45 AM1/24/13
to seleniu...@googlegroups.com
Hello Mark,

I am a newbie with selenium I think I am doing explicit wait:

  var wait = new WebDriverWait(_driver, TimeSpan.FromSeconds(WaitInSeconds));
            wait.Until(ExpectedConditions.ElementIsVisible(By.CssSelector(selector)));

is there a better way?

Mark Collin

unread,
Jan 24, 2013, 11:20:42 AM1/24/13
to seleniu...@googlegroups.com
That looks correct, you can also get the element from the wait, so you can do:

WebElement myElement = wait.Until(ExpectedConditions.ElementIsVisible(By.CssSelector(selector)));
To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/iNXCQSL8TRYJ.

cces...@gmail.com

unread,
Jan 24, 2013, 2:19:35 PM1/24/13
to seleniu...@googlegroups.com
So why I get the error that can't find the element? It does not happen all the time but it does every now and then.

Thank you for validating my code.

cces...@gmail.com

unread,
Jan 24, 2013, 2:22:38 PM1/24/13
to seleniu...@googlegroups.com
Hi Mark,

I am using webdriver version 2.26 , do you think the latest may help?

Mark Collin

unread,
Jan 24, 2013, 5:28:04 PM1/24/13
to seleniu...@googlegroups.com

You would need to show all your code so I can get an idea of what is happening. 

 

In isolation the bits you have shown do not explain the error

To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/gQyTvzhr0HQJ.

cces...@gmail.com

unread,
Jan 24, 2013, 6:40:07 PM1/24/13
to seleniu...@googlegroups.com
I found my problem! I was navigating to the page , and search for an element via the wait I showed to you. The page was not fully loaded throwing the error you saw. 

I added a wait for the page title to wait it seems to fix the issue. Now it finds the element I wanted in the 1st place.

Thanks
Reply all
Reply to author
Forward
0 new messages