Monday, October 25, 2021

selenium 1

#terminal
pip install selenium

#chrome browser
chrome://version/
Google Chrome 94.0.4606.81 (Official Build) (64-bit) (cohort: Stable)

go to https://chromedriver.chromium.org/downloads
download current version driver

download win32.zip and extract to C:/Users/zchen/PycharmProjects/selenium

automate click run button on website
#main.py
import os
from selenium import webdriver
from selenium.webdriver.common.by import By

os.environ['PATH'] += r"C:/Users/zchen/PycharmProjects/selenium"
driver = webdriver.Chrome()
driver.get("https://www.w3schools.com/howto/howto_js_progressbar.asp")
driver.implicitly_wait(30)
runButton = driver.find_element(By.XPATH, '//button[text()="Run"]')
runButton.click()

reference:

locate element

No comments:

Post a Comment