Selenium RC Problems with XPath for a table

I am trying to select the item given by:

/html/body[@id='someid']/form[@id='formid']/div[@id='someid2']/div[@id='']/div[@id='']/div[@id='']/table/tbody[@id='tableid']/tr[7]/td[2]

Now the html of the line I'm trying to select is as follows:

<tr>
<td class="someClass">some text</td>
<td class="someClass2">my required text for verifying</td>
</tr>

I need to check if my required text to check on the page exists .

  • I used selenium.isTextPresent("my required text for verifying");and it does not work

  • So, now I tried with. selenium.isElementPresent("//td[contains(text(),'my required text for verifying')]")
    It works sometimes, but sometimes it gives random glitches.

  • Tried using selenium.isElementPresent(//*[contains(text(),'my required text for verifying')])too ..

How to check this text on a page using selenium?

The problem is not that the page takes time to load. I took screenshots before the crash and found that the page is fully loaded, so it should not be a problem.

- - ?

+3
2

CSS:

assertText(selenium.getText("css=.someClass2"), "my required text for verifying");

, isElementPresent, CSS:

assertTrue(selenium.isElementPresent("css=.someClass2"));

, , :

selenium.waitForCondition("var value = selenium.isElementPresent('css=.someClass2'); value == true", "60000");

XPath, , CSS-:

  • //td [ (@class, 'someClass2')
  • = XPath ( 'TABLEID')/ [7]/ [2]
  • xpath = id ('tableid')/descendant:: td [ (@class, 'someClass2')] [7]
+4

; XPath .

id, ; XPath ; . , , xyz[@id=''] - id, xyz [not (@id)].

, XPath , - :

//tbody[@id='tableid']/tr[7]/td[2]

, , , - - html. , id tbody, , table id?

, . xml , . , xhtml , .

//td[contains(normalize-space(text()),'my required text for verifying')]

, text() - xpath , td (, <td><b>my required text for verifying</b></td>), . , :

//td[contains(normalize-space(string(.)),'my required text for verifying')]

, XPath, string(.) . , :

//td[contains(normalize-space(.),'my required text for verifying')]

, td. , , td , , , "" (, /*[contains(normalize-space(.),'my required text for verifying')]).

+1

Source: https://habr.com/ru/post/1718361/


All Articles