Skip to content Skip to sidebar Skip to footer

Testing User Input Is Mirrored From One Input To Another With Selenium + Python

I am trying to write a test in Selenium that ensures text entered into one input is mirrored in another input. I keep getting this error below. selenium.common.exceptions.NoSuchEle

Solution 1:

The error says it all NoSuchElementException: Message: no such element which is because the xpath you constructed is unable to identify the intended element. Here is the code block for your reference :

driver = self.driver
userInput = "Howdy"
inputBoxOneXpath = driver.find_element_by_xpath("//input[@type='text' and @placeholder='Enter text here...']")
inputBoxOneXpath.clear()
inputBoxOneXpath.send_keys(userInput)
driver.implicitly_wait(10)
inputBoxTwoXpath = driver.find_element_by_xpath("//input[@class='textbox' and @placeholder='Enter text here...']")
assert inputBoxTwoXpath.get_attribute("value") in userInput
driver.close()

Solution 2:

With the provided html, you could do:

userInput = "Howdy"
driver.find_element_by_xpath("//input[@type='text' and @placeholder='Enter text here...']").send_keys(userInput)
driver.find_element_by_xpath("//input[@class='textbox' and @placeholder='Enter text here...']").send_keys(userInput)

Post a Comment for "Testing User Input Is Mirrored From One Input To Another With Selenium + Python"