Forums

Selenium only works with some pages

Hi, I am trying to use selenium (in the console, not in an app) but it only works for some pages. Actually if I try to get the title of www.google.com by using:

from pyvirtualdisplay import Display
from selenium import webdriver

with Display():
    browser = webdriver.Firefox()
    try:
        browser.get('https://www.google.com/')
        print(browser.title)
    finally:
        browser.quit()

I get the correct output: 'Google'. It also works with others pages like amazon. However, if I try with https://www.wsj.com the output is 'Problem loading page'. If I try with the page I am interested in, http://www.renfe.com/, I get just 'Error'. I thought the reason was I was using the free account but after upgrading (to the 'hacker' account) the problems are still there.

Thank you very much in advance.

When I run the above code with the url http://www.renfe.com/, I get the title printed as Renfe.

Could it be that you need to close all your consoles and start them again after your upgrade?

First of all thank you for your response. Unfortunately I have already tried to close all the consoles and start again but that does not solve the problem.

I thought that maybe the reason could be the versions I am using but according to other threads I have read that shouldn't be the problem (I am using selenium 2.53.6 and python 3.5). Just in case, could you tell me the versions you are using?

Thank you once again!

Hmm, I just tried again using selenium 2.53.6 and python 3.5, and I can get a title printed. It does seem like renfe.com is redirecting to a different site though. What is the error that you have been getting? For example, could you do a print(browser.find_element_by_tag_name('body').text) to see if there is any more details?

By the way, I do get an error with wsj.com.

Hi Conrad,

I have already fixed the problem. Actually it was a stupid mistake on my part... If was just writting https instead of http...really sad :)

Thank you

Great! Glad you found the problem.