2022-10-30 11:29:55 +08:00
|
|
|
"""Test that SeleniumBase can autodetect and use xpath selectors."""
|
2019-10-25 13:19:58 +08:00
|
|
|
from seleniumbase import BaseCase
|
2023-02-03 13:27:36 +08:00
|
|
|
BaseCase.main(__name__, __file__)
|
2019-10-25 13:19:58 +08:00
|
|
|
|
|
|
|
|
2021-03-11 06:27:52 +08:00
|
|
|
class XPathTests(BaseCase):
|
2019-10-25 13:19:58 +08:00
|
|
|
def test_xpath(self):
|
2022-02-01 13:59:15 +08:00
|
|
|
self.open("https://seleniumbase.io/demo_page")
|
2022-03-16 09:45:28 +08:00
|
|
|
self.assert_element('//h1[(text()="Demo Page")]')
|
2022-02-01 13:59:15 +08:00
|
|
|
self.type('//*[@id="myTextInput"]', "XPath Test!")
|
2022-03-16 09:45:28 +08:00
|
|
|
self.click('//button[starts-with(text(),"Click Me")]')
|
2022-04-01 06:22:21 +08:00
|
|
|
self.assert_element('//button[contains(., "Purple")]')
|
2022-04-14 01:40:01 +08:00
|
|
|
self.assert_text("SeleniumBase", "//table/tbody/tr[1]/td[2]/h2")
|