Problem using selenium library in pure python

Hello, i’m trying to open a website with selium library, in my machine it works, but in container returns this problem.

/home/worker/instance/runs/55df5daa-556c-422b-8ed5-e7a7dcfe61a7/package/main_freto.py:32: DeprecationWarning: use options instead of chrome_options
[2023-01-11T19:10:04.708]: wd=webdriver.Chrome(chrome_options=chrome_options)
[2023-01-11T19:10:05.326]: Inicio da automacao
[2023-01-11T19:10:05.326]: Traceback (most recent call last):
[2023-01-11T19:10:05.327]: File “/home/worker/instance/runs/55df5daa-556c-422b-8ed5-e7a7dcfe61a7/package/main_freto.py”, line 76, in
[2023-01-11T19:10:05.327]: main = Main()
[2023-01-11T19:10:05.327]: File “/home/worker/instance/runs/55df5daa-556c-422b-8ed5-e7a7dcfe61a7/package/main_freto.py”, line 32, in init
[2023-01-11T19:10:05.327]: wd=webdriver.Chrome(chrome_options=chrome_options)
[2023-01-11T19:10:05.327]: File “/home/worker/.robocorp/holotree/db8072d_b5db08f_79335166/lib/python3.9/site-packages/selenium/webdriver/chrome/webdriver.py”, line 69, in init
[2023-01-11T19:10:05.328]: super().init(DesiredCapabilities.CHROME[‘browserName’], “goog”,
[2023-01-11T19:10:05.328]: File “/home/worker/.robocorp/holotree/db8072d_b5db08f_79335166/lib/python3.9/site-packages/selenium/webdriver/chromium/webdriver.py”, line 92, in init
[2023-01-11T19:10:05.328]: super().init(
[2023-01-11T19:10:05.328]: File “/home/worker/.robocorp/holotree/db8072d_b5db08f_79335166/lib/python3.9/site-packages/selenium/webdriver/remote/webdriver.py”, line 272, in init
[2023-01-11T19:10:05.328]: self.start_session(capabilities, browser_profile)
[2023-01-11T19:10:05.328]: File “/home/worker/.robocorp/holotree/db8072d_b5db08f_79335166/lib/python3.9/site-packages/selenium/webdriver/remote/webdriver.py”, line 364, in start_session
[2023-01-11T19:10:05.329]: response = self.execute(Command.NEW_SESSION, parameters)
[2023-01-11T19:10:05.329]: File “/home/worker/.robocorp/holotree/db8072d_b5db08f_79335166/lib/python3.9/site-packages/selenium/webdriver/remote/webdriver.py”, line 429, in execute
[2023-01-11T19:10:05.329]: self.error_handler.check_response(response)
[2023-01-11T19:10:05.329]: File “/home/worker/.robocorp/holotree/db8072d_b5db08f_79335166/lib/python3.9/site-packages/selenium/webdriver/remote/errorhandler.py”, line 243, in check_response
[2023-01-11T19:10:05.329]: raise exception_class(message, screen, stacktrace)
[2023-01-11T19:10:05.330]: selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: crashed.
[2023-01-11T19:10:05.330]: (unknown error: DevToolsActivePort file doesn’t exist)
[2023-01-11T19:10:05.330]: (The process started from chrome location /usr/bin/chromium-browser is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
[2023-01-11T19:10:05.330]: Stacktrace:

my code:

Hi,
I would highly recommend using rpaframework even in pure python. With RPA.Browser.Selenium You do not need to worry about the chromedriver stuff as the implementations there protect you against storing anything on the system level.

So for example storing webdrivers under C:\Program Files ... is really a quite bad thing as it pretty much binds your robot to just work on your machine as the robot most probably cannot write to that directory on another user or machine. In general only application installers should be writing files there and even those are usually restricted to write read-only files there. The changing dynamic data is not supposed to live under Program Files -folders anyymore.

I will also say that most web automations are just a lot easier to do in Robot Framework, so I it is definitely worth a look. Our courses are free and the first one should just take a few hours, but it gets you started quite nicely with Robot Framework:

…note you can always extend robot framework with pure python stuff so the choice is not RFW or Python as every keyword in Robot Framework has python implementation behind it.

BR, Kari

2 Likes

But if I want to use this library, what I have to do? I develop a bot and I want to test.

You can use Selenium by importing it same way you did with workitems library. Portal has several python robots you can check for implementation ideas.

1 Like

I’ll searche, thanks