XPath for the elements with no ID or Name in Selenium Webdriver

0 votes

I tried to automate the code which with no IDs on many elements, and a lot of elements with the same class names. Need some help in the following questions

<div id="author-taxonomies" class="menu-opened menu-hover-opened-inactive" onmouseover="styleMenuElement(this)" onmouseout="styleMenuElement(this)" onclick="toggleSFGroup(this)">Author</div>
<div id="author-taxonomies-div" class="opened">
    <div id="top-level-menu" class="opened">
        <div id="top-level-menu-item-1" class="as-master">
            <div class="filter-label"> Name</div>
        </div>
        <div id="top-level-menu-item-1" class="as-slave"
            style="top: 525px; left: 34px; z-index: 100; display: none;"> </div>
        <div id="top-level-menu-item-2" class="as-master">
            <div class="filter-label">Title</div>
        </div>
        <div id="top-level-menu-item-2" class="as-slave">
            <div id="top-level-menu-item-2" class="as-slave-title as-slave-title-subgroup"
               >Title</div>
            <div id="top-level-menu-item-2" class="as-slave-body"> </div>
            <div class="as-slave-buffer"> </div>
        </div>
        <div id="top-level-menu-item-3" class="as-master">
            <div class="filter-label">Location</div>
        </div>
        <div id="top-level-menu-item-3" class="as-slave"> </div>
    </div>
</div>

Problem is how to refer specific labels for this menu and the properties with xPath expressions? For example, if I want to:

  1. verify the "Location" label is there
  2. check if "Title" with class "as-slave" is not visible at the moment
Apr 17, 2018 in Selenium by king_kenny
• 3,590 points
841 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

Use like this or similar to this:

  • //div[@id="top-level-menu-item-3"]/div[@class="filter-label"]
  • //div[@id="top-level-menu1"]  for selenium RC

answered Apr 17, 2018 by Meci Matt
• 9,400 points

Related Questions In Selenium

0 votes
1 answer

what is the need of xpath when you have attributes like id ,class,name in selenium?

It is not necessary that every element ...READ MORE

answered Jun 1, 2018 in Selenium by Vinita
• 220 points
61 views
0 votes
1 answer

How to scroll the Page up or down in Selenium WebDriver? (using java)

Its pretty simple. Check out the below ...READ MORE

answered Apr 5, 2018 in Selenium by nsv999
• 5,050 points
4,956 views
0 votes
1 answer

Searching for the element with &nbsp; symbol in selenium

Use Below: //div[@class='Tips' and text()='\u00a0'] READ MORE

answered Apr 20, 2018 in Selenium by Vardy
• 2,280 points
1,050 views
0 votes
1 answer

Between By.XPath and By.ID, which is the better for locating elements?

Technically speaking, By.ID() is the faster technique ...READ MORE

answered May 29, 2018 in Selenium by sniffy_god
• 760 points
685 views
0 votes
1 answer

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,050 points
130 views
0 votes
1 answer
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,130 points
519 views
0 votes
1 answer

How to use such xpath to find web elements

It's much simpler to use: #MyDiv123 > div.super or ...READ MORE

answered Jun 14, 2018 in Selenium by Samarpit
• 5,130 points
118 views
0 votes
1 answer

Check that the element is clickable or not in Selenium WebDriver

Use Selenium Waits: WebDriverWait ...READ MORE

answered Jun 12, 2018 in Selenium by Meci Matt
• 9,400 points
5,539 views
0 votes
1 answer

Which is preferred more in Selenium Absolute or Relative XPath

Absolute XPath is the direct way to ...READ MORE

answered Apr 20, 2018 in Selenium by Meci Matt
• 9,400 points
681 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.