Home > Software engineering >  Selenium: Website always opens with selenium but then the site goes completely white immediately and
Selenium: Website always opens with selenium but then the site goes completely white immediately and

Time:02-14

I try to open the following site using selenium: https://www.honestdoor.com/

Normally this works fine with every site with the following code: (I am currently using google-chrome version 98.0.4758 - using ChromeDriverManager for downloading the version - see below in the code)

from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.support.ui import WebDriverWait
from webdriver_manager.chrome import ChromeDriverManager
from fake_useragent import UserAgent
import time

    if __name__ == '__main__':  
      ua = UserAgent()
      userAgent = ua.random
      options = Options()
      # options.add_argument('--headless')
      options.add_experimental_option ('excludeSwitches', ['enable-logging'])
      options.add_argument("start-maximized")
      options.add_argument('window-size=1920x1080')                               
      options.add_argument('--no-sandbox')
      options.add_argument('--disable-gpu')  
      options.add_argument(f'user-agent={userAgent}')   
      srv=Service(ChromeDriverManager().install())
      driver = webdriver.Chrome (service=srv, options=options)    
      waitWebDriver = WebDriverWait (driver, 10)         
     
    
      link = "https://www.honestdoor.com/"  
      # link = "https://www.bcassessment.ca/"  
      # driver.minimize_window()        # optional
      driver.get (link)       
      time.sleep(1000) 

The site opens with selenium as allways but then the site goes immediately complete white and is still loading forever with the cicle going around in the top left corner (I can only kill the chrome-task in the task manager).

When I open the site in normal chrome or incognito chrome everything works fine - it seem to only crash when I open it with selenium. With other sites (like https://www.bcassessment.ca/ I have no problems at all and the open with selenium as allways)

Why is this not working for this particular website?

CodePudding user response:

Not that super clear about the exact issue you are facing while loading the website. However I was able to load the website using the following code block:

  • Code Block:

    from selenium import webdriver
    from selenium.webdriver.chrome.options import Options
    from selenium.webdriver.chrome.service import Service
    
    options = Options()
    options.add_argument("start-maximized")
    options.add_experimental_option("excludeSwitches", ["enable-automation"])
    options.add_experimental_option('excludeSwitches', ['enable-logging'])
    options.add_experimental_option('useAutomationExtension', False)
    options.add_argument('--disable-blink-features=AutomationControlled')
    s = Service('C:\\BrowserDrivers\\chromedriver.exe')
    driver = webdriver.Chrome(service=s, options=options)
    driver.get("https://www.honestdoor.com/")
    
  • Browser Snapshot:

honestdoor

  • Related