Use headless Chrome + reboot
This commit is contained in:
@@ -1,9 +1,12 @@
|
|||||||
# colocrossing_api.py
|
# colocrossing_api.py
|
||||||
from selenium import webdriver
|
from selenium import webdriver
|
||||||
from selenium.webdriver.support.ui import Select
|
from selenium.webdriver.support.ui import Select
|
||||||
|
from selenium.webdriver.chrome.options import Options
|
||||||
|
|
||||||
# Initialize the WebDriver (make sure you have the appropriate WebDriver installed)
|
# Initialize the WebDriver (make sure you have the appropriate WebDriver installed)
|
||||||
driver = webdriver.Chrome() # You can use other WebDriver options like Firefox, Edge, etc.
|
chrome_options = Options()
|
||||||
|
chrome_options.add_argument('--headless')
|
||||||
|
driver = webdriver.Chrome(options=chrome_options) # You can use other WebDriver options like Firefox, Edge, etc.
|
||||||
|
|
||||||
# URL for login
|
# URL for login
|
||||||
login_url = "https://portal.colocrossing.com/auth/login"
|
login_url = "https://portal.colocrossing.com/auth/login"
|
||||||
@@ -52,7 +55,7 @@ def power_cycle(credentials, device_id):
|
|||||||
# Set the select with name control_action to option 1
|
# Set the select with name control_action to option 1
|
||||||
select = driver.find_element(by="name", value="control_action")
|
select = driver.find_element(by="name", value="control_action")
|
||||||
select_option = Select(select)
|
select_option = Select(select)
|
||||||
select_option.select_by_value("1")
|
select_option.select_by_value("3")
|
||||||
|
|
||||||
# Click the button with class control_pdu_port_button
|
# Click the button with class control_pdu_port_button
|
||||||
button = driver.find_element(by="class name", value="control_pdu_port_button")
|
button = driver.find_element(by="class name", value="control_pdu_port_button")
|
||||||
|
|||||||
Reference in New Issue
Block a user