-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Expand file tree
/
Copy pathtest_hack_search.py
More file actions
35 lines (33 loc) · 1.67 KB
/
test_hack_search.py
File metadata and controls
35 lines (33 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
""" Testing the "self.set_attribute()" and "self.set_attributes()" methods
to modify a Google search into becoming a Bing search.
set_attribute() -> Modifies the attribute of the first matching element.
set_attributes() -> Modifies the attribute of all matching elements. """
from seleniumbase import BaseCase
BaseCase.main(__name__, __file__)
class HackingTests(BaseCase):
def test_hack_search(self):
if self.headless or self.browser != "chrome":
self.open_if_not_url("about:blank")
self.skip('Skip test if headless or not chrome.')
if not self.undetectable:
self.get_new_driver(undetectable=True)
self.open("https://google.com/ncr")
self.click_if_visible('button:contains("Accept all")')
self.hide_elements("iframe")
self.assert_element('[title="Search"]')
self.sleep(0.5)
self.set_attribute('[action="/search"]', "action", "//bing.com/search")
self.set_attributes('[value="Google Search"]', "value", "Bing Search")
self.type('[title="Search"]', "SeleniumBase GitHub Page URL")
self.sleep(0.5)
self.js_click('[value="Bing Search"]')
self.highlight("h1.b_logo", loops=8)
source = self.get_page_source()
self.assert_true("github.com/seleniumbase/SeleniumBase" in source)
self.internalize_links()
self.click('a:contains("seleniumbase/SeleniumBase")')
self.js_click('a[title="examples"]')
self.highlight('#repo-content-turbo-frame')
self.js_click('a[title="test_hack_search.py"]')
self.assert_text("test_hack_search.py", "#file-name-id-wide")
self.highlight("#file-name-id-wide")