Skip to content

Python code snippet – How to host selenium web automation scripts online?

# The same code that Homeless Horse wrote but in Python

from selenium import webdriver					# pip install selenium to work
from selenum.webdriver.common.keys import Keys
driver = webdriver.Chrome()				# Specifying which browser to use
driver.get("https://www.google.com")	# The url of the website to visit
element = driver.find_element_by_name("q") # Find the searchbar element which has the name "q"
element.send_keys("BrowserStack")		# Send in the word "BrowserSTack"
element.send_keys(Keys.RETURN)	# Send in the Return Key(Enter Key)
print(driver.title)		# Print the title of the webpage in the console
driver.quit()		# Close the webdriver
See also  How to make dictionary in Python?
, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.