I need help to automate to click the search button in this webpage. The code works so far, until I reach the search button. Below are the elements for this button. The value named Search is unique for this button.
<input type="button" value="Search" onclick="submitfilter();">
Below is the code:
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait, Select
from selenium.common.exceptions import TimeoutException, NoSuchElementException
from selenium.webdriver.common.by import By
driver = webdriver.Chrome(executable_path='C:/chromedriver.exe')
driver.implicitly_wait(10)
url = "http://fake.com"
driver.get(url)
driver.maximize_window()
ABC = driver.find_element(By.XPATH("//input[@value="Search"]"))
ABC.click()
CodePudding user response:
There is a syntactical error on that line, you're using double quotes for the Xpath and so for the value inside it, which makes the code treat search as a variable.
Change the line to:
ABC = driver.find_element(By.XPATH('//input[@value="Search"]'))
CodePudding user response:
ABC = driver.find_element(By.XPATH,"//input[@value='Search']")
The proper way to write this would be like so. Not calling the By.xpath with the string of the xpat.