python selenium get title 1

python selenium get title

from selenium import webdriver

driver = webdriver.Chrome()
url = "http://name_of_website.com/"
driver.get(url)

print(driver.title)

Here is what the above code is Doing:
1. We import the webdriver module from the selenium package.
2. We create a new instance of Chrome WebDriver.
3. We store the URL of the website we want to test in a variable.
4. We use the get() method to navigate to the URL we stored in the url variable.
5. We print the title of the page to the console.

Similar Posts