Use headless Chrome + reboot

This commit is contained in:
Nik Rozman
2023-09-09 11:38:21 +02:00
parent f9336ff458
commit 59c6a316ee

View File

@@ -1,9 +1,12 @@
# colocrossing_api.py
from selenium import webdriver
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)
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
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
select = driver.find_element(by="name", value="control_action")
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
button = driver.find_element(by="class name", value="control_pdu_port_button")