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
433 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
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,400 points

Related Questions In Selenium

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,050 points
3,841 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,050 points
4,982 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,050 points
1,000 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,400 points
41 views
0 votes
1 answer
0 votes
1 answer

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.