-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
Copy pathgithub_test.py
executable file
·27 lines (25 loc) · 1.27 KB
/
github_test.py
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
from seleniumbase import BaseCase
class GitHubTests(BaseCase):
def test_github(self):
# Selenium can trigger GitHub's anti-automation system:
# "You have triggered an abuse detection mechanism."
# "Please wait a few minutes before you try again."
# To avoid this automation blocker, two steps are being taken:
# 1. self.slow_click() is being used to slow down Selenium actions.
# 2. The browser's User Agent is modified to avoid Selenium-detection
# when running in headless mode.
if self.headless:
self.get_new_driver(
agent="""Mozilla/5.0 """
"""AppleWebKit/537.36 (KHTML, like Gecko) """
"""Chrome/Version 100.0.4896.88 Safari/537.36"""
)
self.open("https://github.com/search?q=SeleniumBase")
self.slow_click('a[href="/seleniumbase/SeleniumBase"]')
self.click_if_visible('[data-action="click:signup-prompt#dismiss"]')
self.assert_element("div.repository-content")
self.assert_text("SeleniumBase", "h2 strong")
self.slow_click('a[title="seleniumbase"]')
self.slow_click('a[title="fixtures"]')
self.slow_click('a[title="base_case.py"]')
self.assert_text("Code", "nav a.selected")