Home > Software engineering >  SyntaxError: Failed to execute 'evaluate' on 'Document': xpath
SyntaxError: Failed to execute 'evaluate' on 'Document': xpath

Time:07-15

Textbox - input

Element:

XPATH: //*[@id="autocomplete_code"]

I am getting syntax error for below statement, what is not correct in this xpath? I tried just with id and both id & class.

account  = driver.find_element(By.XPATH,"//*input[@id='autocomplete_code' and @class = 'account_code_ac inputSearch ui-autocomplete-input']")

CodePudding user response:

changing code as below fixed the syntax error, but still not able to select the search result value with arrow down key

account  = driver.find_element(By.XPATH,"//*[@id='autocomplete_code']")
account.send_keys("1100-1200-200167-620038")
account.send_keys(Keys.ARROW_DOWN)
account.send_keys(Keys.RETURN)

CodePudding user response:

changing code as below works fine:

account =driver.find_element(By.XPATH,"//*[@aria-label='Search an Account']").click()
account  = driver.find_element(By.XPATH,"//*[@id='autocomplete_code']")
account.send_keys("1100-1200-200167-620038")
element = wait.until(EC.visibility_of_element_located((By.XPATH, '//a[contains(@aria-label, "1100-1200-200167-620038")]')))
account.send_keys(Keys.ARROW_DOWN)
account.send_keys(Keys.RETURN)
  • Related