In the Terminal we can see the title of Facebook is being printed as the current page of Web Browser is www.facebook.com.ee the similar window as given below,
Click the File --> Open Folder or Ctrl+K Ctrl+O. Then Navigate to the desired directory where you wish to keep you code and hit Enter.
Click the new file icon and give the name to the file Opening_link.py
Type in the below code on the file Opening_link.py
CODE
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
driver = webdriver.Firefox(executable_path="D:\Software\Selenium\geckodriver-v0.24.0-win64\geckodriver.exe")
driver.get("http://www.facebook.com")
print(driver.title)
EXPLANATION
The selenium webdriver module provides all the WebDriver implementations. Currently we are using WebDriver implementation of Firefox in this tutorial.
from selenium import webdriver
The Keys is a class which provides keys in the keyboard like RETURN, CTRL, ALT and many more.
from selenium.webdriver.common.keys import Keys
Providing the path to the Gecko driver and creating the instances of WebDriver .To know more about Gecko Driver visit this link https://www.guru99.com/gecko-marionette-driver-selenium.html.
driver = webdriver.Firefox(executable_path="D:\Software\Selenium\geckodriver-v0.24.0-win64\geckodriver.exe")
Opening the URL using the driver.get Method, opens the whole argument of the get methods on the FireFox.
driver.get("http://www.facebook.com")
The driver.print method will return the current page title, and we use print method to print them onto our terminal.
print(driver.title)
OUTPUT
Execute the code by Right click the workspace and select Run Python file in Terminal from the drop-down box.
The bot icon on the URL denotes that the browser is opened via WebDriver.
In the Terminal we can see the title of Facebook is beign printed as the current page of Web Browser is www.facebook.com.