Hiiiii,
I want to scratch a text from the web page with simple code:
from selenium import webdriver
# Set options to make browsing easier
#Function is responsible to create a driver and return that driver.
def get_driver():
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument("start-maximized")
chrome_options.add_argument("disable-infobars")
chrome_options.add_argument("disable-dev-shm-usage")
chrome_options.add_argument("no-sandbox")
chrome_options.add_experimental_option("excludeSwitches", ["enable-automation"])
chrome_options.add_argument("disable-blink-features=AutomationControlled")
driver = webdriver.Chrome(options = chrome_options)
#connect driver to a web page
driver.get("http://automated.pythonanywhere.com")
#return driver for this particular web page
return driver
def main():
driver = get_driver()
element = driver.find_element(by = "xpath", value = "/html/body/div[1]/div/h1[1]")
return element.text
print(main())
The error message:
WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally.
(unknown error: DevToolsActivePort file doesn't exist)
(The process started from chrome location /root/.cache/selenium/chrome/linux64/115.0.5790.170/chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
Stacktrace:
#0 0x55e176cd1613
#1 0x55e1769fd537
#2 0x55e176a28588
#3 0x55e176a255d9
#4 0x55e176a65643
#5 0x55e176a64d8f
#6 0x55e176a5c803
#7 0x55e176a3068b
#8 0x55e176a3142e
#9 0x55e176c92c28
#10 0x55e176c96af7
#11 0x55e176ca101c
#12 0x55e176c97723
#13 0x55e176c66457
#14 0x55e176cbb628
#15 0x55e176cbb7b7
#16 0x55e176cca483
#17 0x7efedfacc609 start_thread
---------------------------------------------------------------------------
WebDriverException Traceback (most recent call last)
<command-1651202861729537> in <cell line: 6>()
4 return element.text
----> 6 print(main())
<command-1651202861729537> in main()
1 def main():
----> 2 driver = get_driver()
3 element = driver.find_element(by = "xpath", value = "/html/body/div[1]/div/h1[1]")
4 return element.text
<command-1651202861729536> in get_driver()
---> 14 driver = webdriver.Chrome(options = options)
16 #connect driver to a web page
Can you explain what does this error mean and how can I solve it?
If there isn’t a group near you,
start one
and help create a community that brings people together.
Request a New Group
© Databricks 2024. All rights reserved.
Apache, Apache Spark, Spark and the Spark logo are trademarks of the Apache Software Foundation.
Privacy Notice
|
Terms of Use
|
Your Privacy Choices
|
Your California Privacy Rights