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.

Bharat Mane
6,78512 gold badges42 silver badges69 bronze badges
asked Jan 11, 2017 at 16:19
6
  • It might be a compatibility issue, check your browser versions against selenium version. Commented Jan 11, 2017 at 19:00
  • Doesn't look like its a version issue, checked it with versions which were working before. Commented Jan 11, 2017 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. Commented Jan 15, 2017 at 1:25
  • I guess it's now called Gecko driver. I am using it presently Commented Jan 17, 2017 at 15:17
  • Can you please list Firefox, Selenium and Python versions ? Commented Nov 27, 2017 at 14:01

1 Answer 1

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)
answered Jul 29, 2017 at 2:38

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.