0

I am trying to click a menu item from a navigation bar. I was able to click the first menu item and navigate to that page. But when I tried to navigate to other pages it always gives ElementNotVisibleException.

HTML for the menu items.

<ul id="yw1" class="dropdown-menu">
 <li id="people_add"><a tabindex="-1" href="/index.php/People/add"><i class="fa fa-plus fa-1x "></i> Add People</a></li>
 <li id="people_search"><a tabindex="-1" href="/index.php/people/search"><i class="fa fa-search fa-1x "></i> Search People</a></li>
 <li id="people_merge"><a tabindex="-1" href="/index.php/people/mergeDup"><i class="fa fa-user fa-1x "></i> Merge Duplicates</a></li>
 <li id="bulk_insert"><a tabindex="-1" href="/index.php/BulkInsert/Admin"><i class="fa fa-file fa-1x "></i> Bulk Insert</a></li>
 </ul>

This code works for the first menu item.

driver1.findElement(By.id("people_add")).click();

But It doesn't work for the second menu item or any other.

driver1.findElement(By.id("people_search")).click();

I tried the xpath for the second menu item. but it also didn't work.I still got element not visible exception again.

How can I fix this?

6
  • What exactly do you mean by doesn't work? Do you see any error? Update the question with the error stack trace. Commented Jan 11, 2018 at 11:28
  • is menu item visible always or will be visible only when mouse over on main menu? Commented Jan 11, 2018 at 12:09
  • Possible duplicate of ElementNotVisibleException : Selenium Python Commented Jan 11, 2018 at 12:58
  • I guess there more than one element which id is 'people_search' and the first one is not visible. please confirm this by DevTool manaully to see css selector: #people_search can match how many elements on the problem page. Commented Jan 11, 2018 at 14:39
  • @yong I have only one people_search. Commented Jan 12, 2018 at 5:42

1 Answer 1

0

If you have mutiple frames in your application then try to go to the default content before clicking the second menu item.

driver.switchTo().defaultContent();

driver1.findElement(By.id("people_search")).click();

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.