Your ultimate guide

General Selenium Methods

Selenium Methods:

get(String URL): get method will navigate to a web page given by the URL.
    Example: driver.get("https://testingcolleges.blogspot.com")

title: Get the title of the Current web page.
    Example: driver.title

current_url: Gets the Current web page URL.
    Example: driver.current_url

page_source: Gets the Current web page source code.
    Example: driver.page_source

close(): To close the Current web page window.
    Example: driver.close()

quite(): To close all the current browser windows.
    Example: driver.quite()


Example Program:
  1. from selenium import webdriver
  2. driver = webdriver.Chrome()
  3. # Navigate to a web site
  4. driver.get("https://testingcolleges.blogspot.com")
  5. # To print the title of the current page
  6. pageTitle = driver.title
  7. print(pageTitle)
  8. # To print the current page URL
  9. pageURL = driver.current_url
  10. print(pageURL)
  11. # To close the current browser window
  12. driver.close()
OUT PUT:
  1. Testing Colleges
  2. https://testingcolleges.blogspot.com/




No comments:

Post a Comment