OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

Selenium Running Indefinitely?

  • Thread starter Thread starter Kellen Karls
  • Start date Start date
K

Kellen Karls

Guest
I'm trying to run Selenium in Python to scrape lyrics from Genius.com. For some reason my code runs indefinitely with the browser staying open. Here's the code I'm running:

Code:
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

timeout = 10
driver = launchBrowser(path)

# Get Body Text
body = EC.presence_of_element_located(
    By.CLASS_NAME, "ReferentFragmentdesktop__Highlight-sc-110r0d9-1"
)
WebDriverWait(driver, timeout).until(body)
paragraphs = driver.find_elements(
    By.CLASS_NAME, "ReferentFragmentdesktop__Highlight-sc-110r0d9-1"
)
driver.quit()

I defined launchBrowser and path earlier in the code and am having no issues with that. I would expect my program to either close once the timeout time has been hit in WebDriverWait or once the code gets to driver.quit(). For some reason neither is happening and my browser window stays open perpetually. Any help or advice would be much appreciated.

I've tried scraping other sites and those seem to work fine, but for some reason this code is stuck in a perpetual loop and I'm not sure why. I'm using Chrome.
<p>I'm trying to run Selenium in Python to scrape lyrics from Genius.com. For some reason my code runs indefinitely with the browser staying open. Here's the code I'm running:</p>
<pre><code>from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

timeout = 10
driver = launchBrowser(path)

# Get Body Text
body = EC.presence_of_element_located(
By.CLASS_NAME, "ReferentFragmentdesktop__Highlight-sc-110r0d9-1"
)
WebDriverWait(driver, timeout).until(body)
paragraphs = driver.find_elements(
By.CLASS_NAME, "ReferentFragmentdesktop__Highlight-sc-110r0d9-1"
)
driver.quit()
</code></pre>
<p>I defined launchBrowser and path earlier in the code and am having no issues with that. I would expect my program to either close once the timeout time has been hit in WebDriverWait or once the code gets to driver.quit(). For some reason neither is happening and my browser window stays open perpetually. Any help or advice would be much appreciated.</p>
<p>I've tried scraping other sites and those seem to work fine, but for some reason this code is stuck in a perpetual loop and I'm not sure why. I'm using Chrome.</p>
 

Latest posts

Top