Using switch_to_windows() and printing the title doesn't print the title in Selenium webdriver

0 votes

I am using switch_to_windows() command for printing the title, but it  doesn't print the title in Selenium web driver

Below is the code:

for handle in browser.window_handles:
    print "Handle = ",handle
    browser.switch_to_window(handle);
    element = browser.find_element_by_tag_name("title")
    print element.get_attribute("value")

I am getting the following output

Handle =  {564f8459-dd20-45b8-84bf-97c69f369738}
None
Handle =  {85338322-5e58-4445-8fe3-3e822d5a0caf}
None

After getting the handle I switch to the window and want to print the title. But I not seeing any title. When I see the HTML page I see the title tag there but not able to get it here.

Jun 28, 2018 in Selenium by GandalfDwhite
• 1,320 points
1,422 views

1 answer to this question.

0 votes

The title of the page will not be in a value attribute of the title element, it will be in the text contents of that element.

The correct way to access that text would be browser.find_element_by_tag_name("title").text

Or you can, just access browser.title.

answered Jun 28, 2018 by Meci Matt
• 9,460 points

Related Questions In Selenium

+1 vote
1 answer
0 votes
1 answer

What are the differences between getText() and getAttribute() functions in Selenium WebDriver?

See, both are used to retrieve something ...READ MORE

answered Apr 5, 2018 in Selenium by nsv999
• 5,510 points
9,538 views
0 votes
1 answer

How to scroll the Page up or down in Selenium WebDriver? (using java)

Its pretty simple. Check out the below ...READ MORE

answered Apr 5, 2018 in Selenium by nsv999
• 5,510 points
12,649 views
0 votes
1 answer

How do i change the location where my file gets downloaded in Selenium Webdriver and firefox driver?

There are a couple of errors there. ...READ MORE

answered Apr 12, 2018 in Selenium by nsv999
• 5,510 points
3,073 views
+1 vote
2 answers

Python with Selenium issue: “Chrome is being controlled by automated test software”

from selenium import webdriver chrome_options = webdriver.ChromeOptions() chrome_options.add_experimental_option("useAutomationExtension", False) chrome_options.add_experimental_option("excludeSwitches",["enable-automation"]) driver ...READ MORE

answered Apr 20 in Selenium by Manoj
3,626 views
0 votes
1 answer

How can we use Selenium with Python?

First  Install Python based on the Operating ...READ MORE

answered May 7, 2018 in Selenium by Meci Matt
• 9,460 points
145 views
0 votes
1 answer
0 votes
1 answer