WebElement.isDisplayed() issue

133 views
Skip to first unread message

techi...@gmail.com

unread,
Apr 22, 2015, 12:24:53 PM4/22/15
to seleniu...@googlegroups.com
Hello All,

in my selenium code i see webelement was populated, but isDisplayed is not becoming true.  What is wrong here?  how can i debug below value ?


in Debug i see this value return from webelemnt

 [[[[FirefoxDriver: firefox on XP (b3a5d7b1-70f1-4a72-aaab-5e214e836442)] -> xpath: /*]] -> xpath: //*[not(descendant::table[@class='fltr_tbl'])]/*[not(ancestor::table[@class='fltr_tbl'])]/descendant::td/span[text()='VAM:']/../following-sibling::td[1]/div/descendant::input[@type='text' or @type='password'][1] | //*[not(descendant::table[@class='fltr_tbl'])]/*[not(ancestor::table[@class='fltr_tbl'])]/descendant::*[text()='VAM:']/following::input[@type='text' or @type='password'][1]


but following returns false.
 
 if( element.isDisplayed() )
{
visibleElement = element;
break;
}

Thanks

Gopa Kishore Mindi

unread,
Apr 28, 2015, 10:41:16 AM4/28/15
to seleniu...@googlegroups.com
Hi,

It might be due to the element taking few secs to appear in the UI. WebDriver is trying to find the element in the UI immediately which is not appearing in the UI immediately.
Can you mention the ImplicitTime that you are using in the code?

Thanks,

Gopa

Abhishek Singh

unread,
Apr 29, 2015, 4:06:07 AM4/29/15
to seleniu...@googlegroups.com
Hi Techie,
This looks like a synchronization issue as suggested by Gopa. The Webelement is not present instantaneously , when the WebDriver is trying to find the element in UI. 

To overcome this issue you can use explicit wait until the required web element is present as well as visible.
Once the visible becomes available, you can proceed with other actions.

WebDriverWait wait = new WebDriverWait(driver, 30L);
WebElement element = wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("<<Xpath expression>>")));
 

Please try out this solution and let me know if this works for you.

Also please go through this blog for more info on when to use "visibilityOfElementLocated" or "presenceofelementlocated"


Regards,
Abhishek Singh


On Wednesday, April 22, 2015 at 9:54:53 PM UTC+5:30, techi...@gmail.com wrote:

gorants 456

unread,
Apr 29, 2015, 6:20:22 PM4/29/15
to seleniu...@googlegroups.com
I am doing re try as well but still i see the issues.


initially few seconds page holds different elements then it renders to actual page. Selenium stores all elements when first time page loads ?, in this case I feel page was changed after loading hence selenium wasn't able to find references.?  do i have to reinitialize again?





while( count < RETRY_LIMIT )
{
try
{
textbox = getWebElement( id, byType);
if( textbox == null )
{
throw new StaleElementReferenceException( "The element has still not become visible" );
}
break;
}
catch( StaleElementReferenceException  ex )
{
count++;
}
}


Thanks,

--
You received this message because you are subscribed to a topic in the Google Groups "Selenium Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/selenium-users/OREbNOdyhE8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/694e05b6-8ad7-4c72-a495-73101de7a41f%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

murali seleniumtrainer

unread,
May 2, 2015, 3:07:56 AM5/2/15
to seleniu...@googlegroups.com
Hi..

did you tried with providing the required sleep or wait time until the page is loaded with actual elements and then checking WebElement is displayed or not?

Thank You,
http://seleniumtrainer.com/

gorants 456

unread,
May 4, 2015, 11:53:47 AM5/4/15
to seleniu...@googlegroups.com
I am doing sleep/wait and also re try. i think in my case it will not work as selenium holds different DOM elements may i need to re initialize the selenium objects?

Anand Somani

unread,
May 4, 2015, 12:03:51 PM5/4/15
to seleniu...@googlegroups.com
Sleep / Wait is not good option while doing automation.
I will suggest, find difference between DOM (Before and After Reload) which will help you. Also you can try isDisplayed / isVisible and see responses.

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.

To post to this group, send email to seleniu...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
~ Anand Somani

gorants 456

unread,
May 4, 2015, 12:12:23 PM5/4/15
to seleniu...@googlegroups.com
After page load i have printed html it doesn't have elements what page has,   isDisplayed  is returning false.

Here my question is even though page rendered after few secs ( i am doing re try until page complete rendered) but html content was not updated in selenium code ..


How can i fix this ? what was the issue here.


Anand Somani

unread,
May 4, 2015, 12:18:49 PM5/4/15
to seleniu...@googlegroups.com
Are you aware which element is rendered last ? Need to find out that.. Once you know, Wait for that element to display/visible.
And then you can do what you want on that page (Maybe you do PageFactory.initElement.)




For more options, visit https://groups.google.com/d/optout.



--
~ Anand Somani

gorants 456

unread,
May 4, 2015, 12:27:37 PM5/4/15
to seleniu...@googlegroups.com
No ( page had mulitiple tabs, text boxs), How do we find out which element is rendered last?  can you point me to more examples on PageFactory.initElement?

Reply all
Reply to author
Forward
0 new messages