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– Yu Zhang2017年01月11日 19:00:22 +00:00Commented Jan 11, 2017 at 19:00
-
Doesn't look like its a version issue, checked it with versions which were working before.Ronron– Ronron2017年01月11日 20:05:14 +00:00Commented 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.kirbycope– kirbycope2017年01月15日 01:25:15 +00:00Commented Jan 15, 2017 at 1:25
-
I guess it's now called Gecko driver. I am using it presentlyRonron– Ronron2017年01月17日 15:17:36 +00:00Commented Jan 17, 2017 at 15:17
-
Can you please list Firefox, Selenium and Python versions ?Gaurav– Gaurav2017年11月27日 14:01:05 +00:00Commented Nov 27, 2017 at 14:01
1 Answer 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)
Explore related questions
See similar questions with these tags.