Uncategorized

Selenium Pyhton Tutorial – Find Elements By Tag Name

import time
from csv import writer
#SELENIUM LIBRARIES
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
#REQUIRED FOR HEADLESS PART 1
from selenium.webdriver.chrome.options import Options
#REQUIRED FOR HEADLESS
from selenium.webdriver.chrome.service import Service


#Set location of Chrome Driver
s = Service('/usr/local/bin/chromedriver')

#Set some selenium chrome options
chromeOptions = Options()
chromeOptions.headless = False
driver = webdriver.Chrome(service=s, options=chromeOptions)

list_data = []

def initialize_browser():
    driver.get("InsertYOURURL")
    print("starting_Driver")
    click_button = driver.find_elements(by=By.TAG_NAME, value="h3")
    i = 0
    while i < len(click_button):
        print(click_button[i].text)
        i+=1

initialize_browser()

#driver.quit()