it's me again
I'm having problem to run a selenium script coded in python, i have two users in Ubuntu Server, fabio user and rundeck user,
In fabio user the script works perfect but in rundeck user the script returns error, can anyone help?
I'm using Ubuntu Server 20.4.3 LTS, Google Chrome 103.0.5060.134, ChromeDriver 103.0.5060.134 and Selenium version 4.3.0.
Here my script:
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.common.by import By
chrome_options = Options()
chrome_options.add_argument('--headless')
# optional
chrome_options.add_argument('--no-sandbox')
# optional
chrome_options.add_argument('--disable-dev-shm-usage')
driver = webdriver.Chrome(ChromeDriverManager().install(),options=chrome_options)
driver.get('http://192.168.15.1/me_configuracao_avancada.asp')
user = driver.find_element(By.ID, "txtUser")
user.send_keys("support")
pass_ = driver.find_element(By.ID, "txtPass")
pass_.send_keys("password")
btnLogin = driver.find_element(By.ID, "btnLogin")
btnLogin.click()
driver.get('http://192.168.15.1/reboot.asp',)
reboot = driver.find_element(By.ID, "btnReboot")
reboot.click()
alert = driver.switch_to.alert
alert.accept()
print("Modem Reiniciado!")
And this is the error i receive when i run the script on rundeck user:
/tmp/865-81373-rundeck-node-01-dispatch-script.tmp.py:16: DeprecationWarning: executable_path has been deprecated, please pass in a Service object
driver = webdriver.Chrome(ChromeDriverManager().install(),options=chrome_options)
Traceback (most recent call last):
File "/tmp/865-81373-rundeck-node-01-dispatch-script.tmp.py", line 16, in <module>
driver = webdriver.Chrome(ChromeDriverManager().install(),options=chrome_options)
File "/home/rundeck/.local/lib/python3.8/site-packages/selenium/webdriver/chrome/webdriver.py", line 69, in __init__
super().__init__(DesiredCapabilities.CHROME['browserName'], "goog",
File "/home/rundeck/.local/lib/python3.8/site-packages/selenium/webdriver/chromium/webdriver.py", line 92, in __init__
super().__init__(
File "/home/rundeck/.local/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 277, in __init__
self.start_session(capabilities, browser_profile)
File "/home/rundeck/.local/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 370, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "/home/rundeck/.local/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 435, in execute
self.error_handler.check_response(response)
File "/home/rundeck/.local/lib/python3.8/site-packages/selenium/webdriver/remote/errorhandler.py", line 247, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: DevToolsActivePort file doesn't exist
Stacktrace:
#0 0x562988d36cd3 <unknown>
#1 0x562988b3e968 <unknown>
#2 0x562988b65e92 <unknown>
#3 0x562988b62370 <unknown>
#4 0x562988b5e8fa <unknown>
#5 0x562988b9994a <unknown>
#6 0x562988b93aa3 <unknown>
#7 0x562988b693fa <unknown>
#8 0x562988b6a555 <unknown>
#9 0x562988d7e2bd <unknown>
#10 0x562988d82418 <unknown>
#11 0x562988d6836e <unknown>
#12 0x562988d83078 <unknown>
#13 0x562988d5cbb0 <unknown>
#14 0x562988d9fd58 <unknown>
#15 0x562988d9fed8 <unknown>
#16 0x562988db9cfd <unknown>
#17 0x7fa24a700609 <unknown>
the problem is, i need to run the script in rundeck user
CodePudding user response:
So, i reboot the machine and then the script works in rundeck user
CodePudding user response:
I was also facing similar issue and after adding below mentioned args, issue resolved.
chrome_options = Options()
chrome_options.add_argument('--headless')
chrome_options.add_argument('--disable-setuid-sandbox')
chrome_options.add_argument('--remote-debugging-port=9222')
chrome_options.add_argument('--disable-extensions')
chrome_options.add_argument('start-maximized')
chrome_options.add_argument('--disable-gpu')
chrome_options.add_argument('--no-sandbox')
chrome_options.add_argument('--disable-dev-shm-usage')