3

I am having this weird issue where when I use:

title = driver.title
print('Title is: ' + title)

the title returns blank or empty, it returns blank only on Firefox and with our internal website. When I use Chrome on our website it returns the actual title or if I use FF on different websites they all return the title too.

This test was running fine until a few weeks ago, Our Developers can't figure out what change might be causing this issue, Of course, I can use Wait but our concern is what else might have broken.

  • It might be a compatibility issue, check your browser versions against selenium version. – Yu Zhang Jan 11 '17 at 19:00
  • Doesn't look like its a version issue, checked it with versions which were working before. – Ronron Jan 11 '17 at 20:05
  • Adding to the version suggestion... If you are using a Firefox version greater than 47 you need to switch to the Marionette driver. – kirbycope Jan 15 '17 at 1:25
  • I guess it's now called Gecko driver. I am using it presently – Ronron Jan 17 '17 at 15:17
  • Can you please list Firefox, Selenium and Python versions ? – Gaurav Nov 27 '17 at 14:01
1

I tend to think of the compatibility issue between Selenium and Firefox, please check that first.

Or, it might very well be a timing issue - you are getting the page title at the time it is not set, though I have not experienced similar timing issues with page titles before.

If this is the case, you may apply WebDriverWait with title_is or title_contains Expected Condition function:

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


wait = WebDriverWait(driver, 10)
wait.until(EC.title_contains("desired substring"))

title = driver.title
print('Title is: ' + title)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.