01. Intro

You can control the browser with methods and properties.

Some attributes are methods and others are properties. All the method attributes are ending with round brackets.

 

 

02. Attributes

Command Description Method/Property
maximize_window() Maximizes the current window that webdriver is using Method
driver.get(url) Loads a web page in the current browser session. Method
driver.title Returns the title of the current page. Property
driver.current_url URL of the currently loaded page. Property
driver.refresh() refreshes the current page. Method
driver.get(driver.current_url) refreshes the current page. Method
driver.back() Go one step backward in the browser history. Method
driver.forward() Go one step forward in the browser history Method
driver.page_source Gets the source of the current page. Property
driver.close() Closes the current window Method
driver.quit() Quits the driver and closes every associated window. Method

 

 

03. Code

# Window Maximize
driver.maximize_window()

# Open the URL
driver.get(baseUrl)

# Get Title
title = driver.title
print("Title of the web page is " + title)

# Get Current Url
currentUrl = driver.current_url
print("Current Url of the web page is " + currentUrl)

# Browser Refresh
driver.refresh()
print("Browser Refreshed 1st time")
driver.get(driver.current_url)
print("Browser Refreshed 2nd time")

# Open another Url
driver.get("https://courses.letskodeit.com/login")
currentUrl = driver.current_url
print("Current Url of the web page is " + currentUrl)

# Browser Back
driver.back()
print("Go one step back in browser history")
currentUrl = driver.current_url
print("Current Url of the web page is " + currentUrl)

# Browser Forward
driver.forward()
print("Go one step forward in browser history")
currentUrl = driver.current_url
print("Current Url of the web page is " + currentUrl)

# Get Page Source
#pageSource = driver.page_source
#print(pageSource)

# Browser Close / Quit
# driver.close()
driver.quit()

 

 

04. Result

 

This blog is for studying selenium webdriver in English. So English maybe not be enough.
Reference: Udemy | Selenium WebDriver with Pyrhon 3.x - Novice To Ninja
              https://www.udemy.com/course/selenium-webdriver-with-python3/

'Testing Automation > 01. Selenium' 카테고리의 다른 글

06. Selenium | Wait ( Implicit / Explicit)  (0) 2022.03.05
05. Selenium | Alert  (0) 2022.03.04
04. Selenium | Browser navigation  (0) 2022.03.04
02. Selenium | Finding Element  (0) 2022.01.08
01. Selenium | Setting  (0) 2021.11.26

+ Recent posts