-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsendingkeys.py
33 lines (24 loc) · 849 Bytes
/
sendingkeys.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
import os
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
PATH = "C:\Program Files (x86)\chromedriver.exe"
driver = webdriver.Chrome(PATH)
driver.get(
"https://www.seleniumeasy.com/test/basic-first-form-demo.html")
driver.implicitly_wait(5)
# Remove any kind of unwanted Ads
try:
removeAd = driver.find_element_by_class_name('at-cm-no-button')
removeAd.click()
except:
print('No Add element found')
# Using Keys to edit inputs
sum1 = driver.find_element_by_id('sum1')
sum2 = driver.find_element_by_id('sum2')
sum1.send_keys(Keys.NUMPAD1, Keys.NUMPAD5)
sum2.send_keys(Keys.NUMPAD1, Keys.NUMPAD5)
# to achieve total sum button use css_selectors
total_sum = driver.find_element_by_css_selector(
'button[onclick="return total()"]')
total_sum.click()
# There are tons Css selectors You can use