Situatie
Selenium is a powerful tool for controlling the web browser through the program. It is functional for all browsers, works on all major OS and its scripts are written in various languages i.e Python, Java, C#, etc, we will be working with Python. Selenium Python bindings provide a convenient API to access Selenium WebDrivers like Firefox, Ie, Chrome, Remote, etc.
Solutie
Pasi de urmat
To install this module type the below command in the terminal.
pip install selenium
Web Drivers: Selenium requires a web driver to interface with the chosen browser.Web drivers is a package to interact with web browser. It interacts with the web browser or a remote web server through a wire protocol which is common to all.
Selenium.get()
This method is used to launch a new browser and will open the given URL in the browser.
Syntax:
driver.get(url)
Parameters used:
The function accept only one argument which is the desired link to be opened as showed in above syntax.
#importing webdriver from selenium
from selenium import webdriver
#selecting Firefox as the browser
#in order to select Chrome
# webdriver.Chrome() will be used
driver = webdriver.Firefox(executable_path = ‘/path/to/geckodriver’)
#URL of the website
url = “https://www.geeksorg/”
#opening link in the browser
driver.get(url)
Leave A Comment?