!!

Welcome to Selenium Webdriver Forum

As a web user you can read and search through forum content. Once you have registered and signed you can post topics, post replies, set up watch lists, modify forum settings, and use private messaging.

Author Topic: Unable to locate an element.  (Read 495 times)

Offline Abc007

  • Selenium User
  • *
  • Posts: 4
Unable to locate an element.
« on: September 07, 2013, 05:44:48 AM »
I am unable to locate the logout option in a dropdown list. Here is the HTML code:
<form method="GET" action="/logout" name="frmTopMenu">
<div style="display:none">
</form>
<li>
<a onclick="document.frmTopMenu.submit();" href="#">
<div style="float:left;">
</a>
</li>
</ul>
</dd>
</dl>


Xpath given by firebug which doesn't work:
.//*[@id='ulglobal']/li[8]/a/div


I am using selenium webdriver with python.

Offline Andrew_

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 292
Re: Unable to locate an element.
« Reply #1 on: September 09, 2013, 02:23:18 AM »
There is no dropdown or ulglobal node visible in the HTML snippet.

Offline Abc007

  • Selenium User
  • *
  • Posts: 4
Re: Unable to locate an element.
« Reply #2 on: September 09, 2013, 02:54:55 AM »
I am copying it again with those details:
<input id="pageHelpUrl" type="hidden" value="#Home_Page"/>
<dl class="dropdown" style="float:right; margin-right:9px; margin-top:0px;">
<dt>
<dd>
<ul id="ulglobal" style="display: block;">
<li>
<li>
<li>
<li>
<li>
<li>
<li>
<form method="GET" action="/logout" name="frmTopMenu">
<li>
<a onclick="document.frmTopMenu.submit();" href="#">
<div style="float:left;">
<img title="Logout" alt="Logout" src="site_media/images/logout_icon.png" style="float:left; margin-top:6px; margin-right:5px; margin-left:16px;"/>
Logout
</div>
</a>
</li>
</ul>
</dd>
</dl>





Error:
    raise exception_class(message, screen, stacktrace)
ElementNotVisibleException: Message: u'Element is not currently visible and so may not be interacted with' ; Stacktrace: Method fxdriver.preconditions.visible threw an error in file:///c:/users/admini~1/appdata/local/temp/2/tmpqh9bo9/extensions/fxdriver@googlecode.com/components/command_processor.js

Selenium Webdriver

Re: Unable to locate an element.
« Reply #2 on: September 09, 2013, 02:54:55 AM »

Offline Andrew_

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 292
Re: Unable to locate an element.
« Reply #3 on: September 09, 2013, 03:18:06 AM »
Yikes.  An image in a div in a link in a list item.

Are you just wanting to click the logout image?  If so, you could try

//img[@Title='Logout']


Obviously, the combox box has to be interacted with first to try & make the node visible.

Offline Abc007

  • Selenium User
  • *
  • Posts: 4
Re: Unable to locate an element.
« Reply #4 on: September 09, 2013, 03:29:36 AM »
I tried with it, also tried with "//img[@alt='Logout']". Same issue, unable to indentify.

Logout is an option in a dropdown list and it has image at the start as well. We can click on image or text. I am fine with click on text.
« Last Edit: September 09, 2013, 06:02:30 AM by Abc007 »

Offline Andrew_

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 292
Re: Unable to locate an element.
« Reply #5 on: September 09, 2013, 05:39:41 AM »
Normally with visibility issues it's either

a) The element literally isn't visible when the lookup takes place.  This normally means that (for example) the dropdown hasn't been clicked, or that there is a timing/race-condition issue and the lookup is occurring before the element renders.

b) A parent is marked as hidden - this can occasionally have some strange effects wrt element visibility.

You could try putting a sleep in before the click to see if it's a timing issue.  If it is, you can rework it into a more maintainable explicit wait.

Offline Abc007

  • Selenium User
  • *
  • Posts: 4
Re: Unable to locate an element.
« Reply #6 on: September 09, 2013, 05:53:51 AM »
I have tried putting a sleep still the same issue.

Offline DAM

  • Selenium User
  • *
  • Posts: 18
Re: Unable to locate an element.
« Reply #7 on: September 09, 2013, 11:45:58 PM »
I am using selenium with Java for selecting items from the dropdown given the code blow see if this helps

Select project1 = new Select(wd.findElement(By.id("Element")));
project1.selectByVisibleText("dropdown items");

and for identifying the images and browser pop-up you can use Auto-IT tool integrated with selenium even sikuli will help

 

Related Topics

  Subject / Started by Replies Last post
5 Replies
1676 Views
Last post February 23, 2012, 08:01:38 PM
by Mark Collin
5 Replies
1039 Views
Last post April 15, 2012, 05:42:49 PM
by Abrar Mohammed
6 Replies
777 Views
Last post May 01, 2012, 09:43:10 PM
by sita maram
1 Replies
864 Views
Last post May 01, 2012, 09:54:14 PM
by gkarcher
1 Replies
1096 Views
Last post May 17, 2012, 07:16:48 PM
by Michael Tamm
3 Replies
904 Views
Last post December 23, 2012, 10:11:55 PM
by sunsetbloom
2 Replies
510 Views
Last post September 18, 2013, 01:56:10 AM
by abhi