I have been testing some new browser automation tools. One of them being Selenium. One thing I am working on is using Python to open a web page. Go to that web page and look for a certain button. If the button says "Yes Button" do nothing and just refresh the page. If the button changes after a refresh to "No Button" then click on that button. I will post the code below. The only thing I left out is my website address. Any help is really appreciated. Currently my script below does the refresh part but when the button changes to "No Button" it just stops and will not click on the button. I am not sure if my while loop is wrong or my understanding of Selenium.
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions
from selenium.webdriver.common.by import By
import time
################import the chrome web driver and define the location###############
PATH = "c:\Program Files (x86)\chromedriver.exe"
driver = webdriver.Chrome(PATH)
###################################################################################
###########open the web page and print the title##############
driver.get("https://mywebsite.com")
print(driver.title)
time.sleep(1)
##############################################################
#Look for search button and wait for it to change to something else.
while True:
searchbutton = WebDriverWait(driver, 60).until(expected_conditions.presence_of_element_located((By.LINK_TEXT, "Yes Button")))
driver.refresh()
else:
searchbutton = driver.find_element_by_link_text("No Button")
searchbutton.click()