-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathselenium_driver2.py
More file actions
56 lines (39 loc) · 1.51 KB
/
Copy pathselenium_driver2.py
File metadata and controls
56 lines (39 loc) · 1.51 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
47
48
49
50
51
52
53
54
55
56
#I have this for practice. Using generative AI to master some automation principles
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.service import Service
#from webdriver_manager.chrome import ChromeDriverManager
import time
import configparser
# Initialize the Chrome WebDriver
# Using ChromeDriverManager to automatically handle driver installation
#service = Service(SafariDriverManager().install())
driver = webdriver.Chrome().get_network_conditions
#driver = webdriver.Safari('./safaridriver')
help(driver)
'''
try:
# Navigate to a website
driver.get("https://www.selenium.dev/selenium/web/web-form.html")
# Assert the title of the page
assert "Web form" in driver.title
# Find the text input element by its name
text_box = driver.find_element(By.NAME, "my-text")
# Find the submit button by its tag name
submit_button = driver.find_element(By.TAG_NAME, "button")
# Type text into the input field
text_box.send_keys("Selenium is awesome!")
# Click the submit button
submit_button.click()
# Find the message element after submission
message_element = driver.find_element(By.ID, "message")
# Assert that the message confirms submission
assert "Received!" in message_element.text
print("Test passed: Form submitted successfully.")
except Exception as e:
print(f"Test failed: {e}")
finally:
# Close the browser
time.sleep(10) # Pause to see the result before closing
driver.quit()
'''