-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathselenium_form_inputs.py
39 lines (31 loc) · 1.18 KB
/
selenium_form_inputs.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
28
29
30
31
32
33
34
35
36
37
38
39
import selenium.common.exceptions
def search_website():
from selenium import webdriver
from selenium.webdriver.common.by import By
import selenium.common.exceptions
import time
driver = webdriver.Chrome()
driver.get("https://accounts.lambdatest.com/register")
try:
name = driver.find_element(By.XPATH, "//input[@id='name']")
email = driver.find_element(By.XPATH, "//input[@id='email']")
userpassword = driver.find_element(By.XPATH, "//input[@id='userpassword']")
phone = driver.find_element(By.XPATH, "//input[@id='phone']")
except selenium.common.exceptions.NoSuchElementException as e:
raise Exception(e)
else:
name.send_keys("Selenium Software")
email.send_keys("[email protected]")
userpassword.send_keys("strongpassword123!@#")
phone.send_keys("8347384828")
# Get element for button
try:
submit_button = driver.find_element(By.XPATH, "//button[@type='submit']")
except selenium.common.exceptions.NoSuchElementException as e:
raise e
else:
submit_button.submit()
time.sleep(10)
driver.quit()
if __name__ == '__main__':
search_website()