-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhelpers.py
More file actions
29 lines (23 loc) · 1.1 KB
/
Copy pathhelpers.py
File metadata and controls
29 lines (23 loc) · 1.1 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
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.action_chains import ActionChains
import os
def getChromeDriver():
chromedriver = "/usr/local/bin/chromedriver"
os.environ["webdriver.chrome.driver"] = chromedriver
chrome_options = Options()
# This make Chromium reachable
chrome_options.add_argument("--no-sandbox")
# Overrides default choices
chrome_options.add_argument("--no-default-browser-check")
chrome_options.add_argument("--disable-user-media-security=true")
chrome_options.add_argument("--use-fake-ui-for-media-stream")
return webdriver.Chrome(chromedriver, chrome_options=chrome_options)
def setValue(browser, i, j, val):
# Websudoku has reversed row and col index
cellId = 'c' + str(j) + str(i)
cell = browser.find_element_by_id(cellId).find_element_by_tag_name('input')
browser.execute_script("arguments[0].value = arguments[1]", cell, val)
def submit(browser):
cell = browser.find_element_by_css_selector("input[name='submit']")
ActionChains(browser).click(cell).perform()