-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
24 lines (18 loc) · 919 Bytes
/
Copy pathmain.py
File metadata and controls
24 lines (18 loc) · 919 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import selenium
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
# Need to install chromedriver
driver = webdriver.Chrome('C:/Users/andre.nguyen/Downloads/chromedriver_win32/chromedriver.exe')
driver.get('http://codepad.org/')
# Open inspector and right click the html element and select copy XPath to get the link
driver.find_element(By.XPATH, '//*[@id="editor-form"]/table/tbody/tr[2]/td[1]/nobr[10]/label/input').click()
try:
textScreen = driver.find_element(By.XPATH, '//*[@id="textarea"]')
textScreen.send_keys(Keys.TAB)
textScreen.clear()
textScreen.send_keys("print(\"Hello World\")")
except selenium.common.exceptions.NoSuchElementException:
print("Error")
driver.close()
driver.find_element(By.XPATH, '//*[@id="editor-form"]/table/tbody/tr[3]/td/table/tbody/tr/td/div/table/tbody/tr/td[3]/button').click()