Skip to content

Commit 2316ddd

Browse files
committed
Add an example test with XPath selectors
1 parent a886299 commit 2316ddd

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

examples/xpath_test.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
""" NOTE: Using CSS Selectors is better than using XPath!
2+
XPath Selectors break very easily with website changes. """
3+
4+
from seleniumbase import BaseCase
5+
6+
7+
class MyTestClass(BaseCase):
8+
9+
def test_xpath(self):
10+
self.open("https://xkcd.com/1319/")
11+
self.assert_element('//img')
12+
self.assert_element('/html/body/div[2]/div[2]/img')
13+
self.click("//ul/li[6]/a")
14+
self.assert_text("xkcd.com", "//h2")

0 commit comments

Comments
 (0)