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,541 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
10,178 views
0 votes
2 answers

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

JavascriptExecutor jsx = (JavascriptExecutor)driver; jsx.executeScript("window.scrollBy(0,555)", ""); or Action classes ...READ MORE

answered Sep 5 in Selenium by Sri
• 2,970 points
13,194 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,279 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,946 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
156 views
0 votes
1 answer
0 votes
1 answer