0

I am using Selenium/Webdriver in a Python script on Ubuntu. The code below makes it successfully through about 25 iterations in the for loop, and then gets the error:

selenium.common.exceptions.WebDriverException: Message: unknown error: DevToolsActivePort file doesn't exist

I researched the issue and made sure I followed the suggestions to update Chromedriver and Google Chrome, as well as put in the disable-dev-usage argument in Chrome options. Here's the full code:

options = webdriver.ChromeOptions() 
options.add_argument('--no-sandbox')
options.add_argument('--window-size=1420,1080')
options.add_argument('--headless')
options.add_argument('--disable-dev-shm-usage')
options.add_argument('--disable-gpu')
options.add_argument("--disable-notifications")
options.add_experimental_option('useAutomationExtension', False)
options.binary_location='/usr/bin/google-chrome-stable'
chrome_driver_binary = "/usr/bin/chromedriver"
driver = webdriver.Chrome(chrome_driver_binary, chrome_options=options)



# Get base url
base_url = 'https://www.bandsintown.com/?place_id=ChIJOwg_06VPwokRYv534QaPC8g&page='

events = []
eventContainerBucket = []

for i in range(1,55):
    driver = webdriver.Chrome(chrome_driver_binary, chrome_options=options)
    #cycle through pages in range
    driver.get(base_url + str(i))
    pageURL = base_url + str(i)
    print(pageURL)
    
    # get events links
    event_list = driver.find_elements_by_css_selector('div[class^=_3buUBPWBhUz9KBQqgXm-gf] a[class^=_3UX9sLQPbNUbfbaigy35li]')
   
    # collect href attribute of events in even_list
    events.extend(list(event.get_attribute("href") for event in event_list))

    driver.close()


# iterate through all events and open them.
item = {}
allEvents = []
for event in events:
  
    driver = webdriver.Chrome(chrome_driver_binary, chrome_options=options)
    driver.get(event)

    #Do some things here

driver.close()  

Chromedriver version:

ChromeDriver 80.0.3987.149 (5f4eb224680e5d7dca88504586e9fd951840cac6-refs/branch-heads/3987_137@{#16})

Google Chrome stable version:

Google Chrome 80.0.3987.149 

What can I try next?

halfer
  • 19,824
  • 17
  • 99
  • 186
DiamondJoe12
  • 1,879
  • 7
  • 33
  • 81
  • possible duplicate : https://stackoverflow.com/questions/50642308/webdriverexception-unknown-error-devtoolsactiveport-file-doesnt-exist-while-t – SeleniumUser Mar 31 '20 at 14:42
  • @DipakBachhav - I've read through that thread and followed all the answers there - none seem to work. – DiamondJoe12 Mar 31 '20 at 14:49
  • I haven't seen any credible answer that fixes this problem. I'd be interested in knowing if running the tests ..same thing 55 times caused the Chrome to crash. Can you see what is memory/CPU consumption is during and after the tests. – demouser123 Mar 31 '20 at 15:10
  • probably a timing issue. You should try putting a sleep in between closing the driver and re-spawning. I think Chrome needs time to cleanup after the driver closes it and if a new driver session is created before that's finished it can cause problems. – pcalkins Mar 31 '20 at 19:16

0 Answers0