Forums

Having trouble with page loading on chromedriver

I have read (I believe) all of the posts on chromedriver/selenium in the forum.

I can run my code locally, but for some reason I can't on pythonanywhere. I am trying to use LinkedIn with chromedriver. For some reason the page (not the initial linkedin home page, but a page within the login) seems to stall in a loading state.

A few notes: - I am using the free pythonanywhere account - I believe LinkedIn is on the whitelist of sites - I am setting a cookie via chromedriver (e.g., driver.add_cookie) to set the login cookie.

I am following the instructions for the setup (which works):

chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument("--headless")
chrome_options.add_argument("--disable-gpu")
chrome_options.add_argument("--disable-dev-shm-usage")
chrome_options.add_argument("--no-sandbox")
driver = webdriver.Chrome(chrome_options=chrome_options)

I can see the initial LinkedIn page loaded (with no CSS) which I assume is fine. I then set the login cookie. After I go to the page I want, and that page doesn't fully load. When I use driver.get_screenshot_as_file I can see the page is not loaded because the screenshot just shows a LinkedIn icon. Also when I dump the html - print(driver.page_source, file=sys.stderr) I confirm that the page doesn't fully load.

I have tried time.sleep(30) and waiting until a specific element loads, but neither works.

Any suggestions?:

If it's not loading the CSS styles, then it is probably also not loading the javascript for the page and that is why it is not rendering the page. We have www.linkedin.com on the whitelist because it is part of their API, but adding the static endpoints to the whitelist is not something that we are going to do. If you want to access linked in, use the API.