Hi,
from all I can tell, this works just fine.
test.html:
<html>
<head>
<title>This is the title</title>
</head>
<body>
<div>This is div AA</div>
<div>This is div BB</div>
<div>This is div BB</div>
<div>This is div CC</div>
</body>
</html>
test.tcl:
package require Itcl
package require Testing
package require WebDriver
itcl::class MyTests {
inherit Testing::TestObject
method test_find_by_xpath_containing_text {} {
set caps [namespace which [WebDriver::Capabilities #auto -browser_name firefox]]
set window [$session active_window]
$session set_logging_enabled true
$window set_url file://[pwd]/test.html
set div_list [$window elements by_xpath {//*[contains(text(), 'BB')]}]
puts [[lindex $div_list 0] text]
itcl::delete object $session
}
}
exit [[MyTests #auto] run $::argv]
output:
* EXERCISING TESTS IN "MyTests"
* Test 1/1: MyTests::test_find_by_xpath_containing_text -------------- START
- Log:
WebDriver[28eb67df-c5fe-4986-8219-1ed54d3e3e34]: open 'file:///home/tobias/TMP/test.html'
WebDriver[28eb67df-c5fe-4986-8219-1ed54d3e3e34]: get elements by xpath '//*[contains(text(), 'BB')]'
WebDriver[28eb67df-c5fe-4986-8219-1ed54d3e3e34]: got elements 0, 1
WebDriver[28eb67df-c5fe-4986-8219-1ed54d3e3e34]: element 0 text: This is div BB
This is div BB
- Verdict: PASS 00 min 02 sec 013 ms
Best regards,
Tobias