Selenium can't find element

user2869231

I am having trouble accessing elements:

<fieldset>
  <legend>
    Legend1
  </legend>
  <table width=100%" cellspacing="3" bgcolor="white">
    <tbody>
      <tr>...</tr>
      <tr>...</tr>
    </tbody>
  </table>
  <fieldset>
    <legend>
      Legend2
    </legend>
    <table width="100%" cellspacing="3" bgcolor="white" align="center">
      <tbody>
        <tr>
          <td></td>
          <td class="reportLabel" nowrap="">Label1</td>
          <td class="reportField>Field1</td>
          <td></td>
        </tr>
      </tbody>
    </table>
    <fieldset>
       ...

I can access everything in the first table (before entering a sub-fieldset). However, I can't access anything from the fieldset on. The error I get is:

Message: Unable to find element with xpath == ...

Is there something special I have to do when there are new fieldsets? Similar to having to switch frames?

The command I'm using is:

ret = self.driver.find_element_by_xpath("//fieldset/legend[text()='Legend2']/following::table/tbody/tr/td[@class='reportlabel'][text()='Label1']")

The reason I'm including the legend and following it with 'following' is that there are a lot of different sections and legends within a previous one, and I'd like to ensure that the field is indeed in the proper section.

I have also tried simpler things, though, such as:

ret = self.driver.find_element_by_xpath("//fieldset/table/tbody/tr/td[@class='reportLabel][text()='Label1']")

I am using:

IE11 (same issue on Firefox, though)
Selenium 2.44.0
Python 2.7
Windows 7
32 bit IEDriverServer.exe

Does anyone know why I can't access these elements?

Saifur

Your second XPATH looks correct unless the fact that you are missing a ' after reportLabel. Corrected:

//fieldset/table/tbody/tr/td[@class='reportLabel'][text()='Label1']

Working xpath as per OP's comment

//legend[contains(.,'Legend2')]//..//td[contains(text(),'Label1')]

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Selenium IDE can't find an element

From Dev

Can't find an element Selenium Python

From Dev

Can't find element by id using selenium

From Dev

Can't find element selenium python

From Dev

can't find my element (selenium beginner)

From Dev

Selenium WebDriver can't find element by link text

From Dev

Selenium WebDriver can't find element by @FindBy annotation

From Dev

Python Selenium: Can't find the login element of costar.com

From Dev

Can't print a browser.find_element_by_xpath with Selenium in python

From Dev

selenium python css selector can't find element

From Dev

Selenium / xpath - Can't find element, finding parent div

From Dev

Selenium can not find javascript element

From Dev

Selenium - driver.find_element_by_css_selector can't find the element (python)

From Dev

Selenium - driver.find_element_by_css_selector can't find the element (c#)

From Dev

Selenium can't locate this element

From Dev

Selenium didn't find existing element

From Dev

Javascript: can't find element

From Dev

Can't find element in frame

From Dev

Can't find element in frame

From Dev

Can't find an element by "querySelector"

From Dev

Can't find elements of element

From Dev

I am trying to use selenium to load a waiting list and click the button, but I can't seem to find the element

From Dev

I am trying to use selenium to load a waiting list and click the button, but I can't seem to find the element

From Dev

Python.Selenium. Can't find existing element. How switch frame

From Dev

Can't read an xpath element with selenium

From Dev

Capybara with Selenium: Can't click on hidden element

From Dev

Capybara with Selenium: Can't click on hidden element

From Dev

Can't get element by css selector in Selenium

From Dev

Can't locate element with selenium webdriver on python

Related Related

  1. 1

    Selenium IDE can't find an element

  2. 2

    Can't find an element Selenium Python

  3. 3

    Can't find element by id using selenium

  4. 4

    Can't find element selenium python

  5. 5

    can't find my element (selenium beginner)

  6. 6

    Selenium WebDriver can't find element by link text

  7. 7

    Selenium WebDriver can't find element by @FindBy annotation

  8. 8

    Python Selenium: Can't find the login element of costar.com

  9. 9

    Can't print a browser.find_element_by_xpath with Selenium in python

  10. 10

    selenium python css selector can't find element

  11. 11

    Selenium / xpath - Can't find element, finding parent div

  12. 12

    Selenium can not find javascript element

  13. 13

    Selenium - driver.find_element_by_css_selector can't find the element (python)

  14. 14

    Selenium - driver.find_element_by_css_selector can't find the element (c#)

  15. 15

    Selenium can't locate this element

  16. 16

    Selenium didn't find existing element

  17. 17

    Javascript: can't find element

  18. 18

    Can't find element in frame

  19. 19

    Can't find element in frame

  20. 20

    Can't find an element by "querySelector"

  21. 21

    Can't find elements of element

  22. 22

    I am trying to use selenium to load a waiting list and click the button, but I can't seem to find the element

  23. 23

    I am trying to use selenium to load a waiting list and click the button, but I can't seem to find the element

  24. 24

    Python.Selenium. Can't find existing element. How switch frame

  25. 25

    Can't read an xpath element with selenium

  26. 26

    Capybara with Selenium: Can't click on hidden element

  27. 27

    Capybara with Selenium: Can't click on hidden element

  28. 28

    Can't get element by css selector in Selenium

  29. 29

    Can't locate element with selenium webdriver on python

HotTag

Archive