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.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"/html/body/div/div[2]/div/div/div/div[2]/div[1]/input[1]"}
This is the code I'm using currently:
class inputMirror(unittest.TestCase):
def setUp(self):
self.driver = webdriver.Chrome()
self.driver.get("https://foo.bar")
def test_mirror_input(self):
#Ensures text from the first input is mirrored into the second input box
driver = self.driver
userInput = "Howdy"
inputBoxOneXpath = driver.find_element_by_xpath('/html/body/div/div[2]/div/div/div/div[2]/div[1]/input[1]')
inputBoxTwoXpath = driver.find_element_by_xpath('/html/body/div/div[2]/div/div/div/div[2]/div[1]/input[2]')
inputBoxOneXpath.clear()
inputBoxOneXpath.send_keys(userInput)
driver.implicitly_wait(10)
assert inputBoxTwoXpath.text == userInput
driver.close()
HTML code:
<input type="text" placeholder="Enter text here..." value="">
<input class="textbox" placeholder="Enter text here..." value="" maxlength="80" required="true">