-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_example.py
More file actions
47 lines (37 loc) · 1.29 KB
/
Copy pathtest_example.py
File metadata and controls
47 lines (37 loc) · 1.29 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
36
37
38
39
40
41
42
43
44
45
46
# test_example.py
import pytest
from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
@pytest.fixture
def driver(request):
browser = request.config.getoption('--browser')
version = request.config.getoption('--version')
platform = request.config.getoption('--platform')
capabilities = {
"browserName": browser,
"version": version,
"platform": platform,
"selenium:options": {
"debugConnectToRunningApp": True,
"browserName": browser,
}
}
driver = webdriver.Remote(
command_executor='http://a9a62f8fea028418b89cc1c7fae3c67f-808020604.us-east-1.elb.amazonaws.com:4444/wd/hub',
desired_capabilities=capabilities
)
yield driver
driver.quit()
def test_example(driver):
driver.get("https://example.com")
assert driver.title == "Example Domain"
# Interaction with web elements
search_input = driver.find_element_by_name("q")
search_input.send_keys("GitHub Actions")
search_input.submit()
# Verify search results
search_results = driver.find_elements_by_css_selector("h3")
assert len(search_results) > 0
# Print search results titles
for result in search_results:
print(result.text)