Skip to content

Commit 7da5da1

Browse files
committed
Add test demonstrating set_attribute() and set_attributes()
1 parent f562e0d commit 7da5da1

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

examples/test_hack_search.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
""" Testing the "self.set_attribute()" and "self.set_attributes()" methods
2+
to modify a Google search into becoming a Bing search.
3+
set_attribute() -> Modifies the attribute of the first matching element.
4+
set_attributes() -> Modifies the attribute of all matching elements. """
5+
6+
from seleniumbase import BaseCase
7+
8+
9+
class HackingTest(BaseCase):
10+
11+
def test_hack_search(self):
12+
self.open("https://google.com/ncr")
13+
self.assert_element('input[title="Search"]')
14+
self.set_attribute('[action="/search"]', "action", "//bing.com/search")
15+
self.set_attributes('[value="Google Search"]', "value", "Bing Search")
16+
self.update_text('input[title="Search"]', "SeleniumBase GitHub")
17+
self.click('[value="Bing Search"]')
18+
self.assert_element("h1.b_logo")
19+
self.click('[href*="github.com/seleniumbase/SeleniumBase"]')
20+
self.assert_element('[href="/seleniumbase/SeleniumBase"]')
21+
self.assert_true("seleniumbase/SeleniumBase" in self.get_current_url())
22+
self.click('[title="examples"]')
23+
self.assert_text('examples', 'strong.final-path')

0 commit comments

Comments
 (0)