I am using Selenium to enter data on a web page, but have run into an issue with one of the input fields. This is the HTML code causing my difficulty:
<div class="form-group">
<label for="address">Enter your address</label>
<input type="text" name="address" class="form-control" value="" style="font-size:1.8em;padding:15px;height:40px">
<label for="address">Enter this code: 2784873 </label>
<input type="text" name="code" class="form-control" value="" style="font-size:1.8em;padding:15px;height:40px">
I want to use Selenium to copy the numeric value after Enter this code: 2784873
(in this case, 2784873), which I would then enter in the input field below, but so far have been unable to figure out how to get this. I tried using driver.find_element_by_id()
but that was unsuccessful. I also tried using xpath (which seems to me like the best approach) with:
codes = driver.find_elements(By.XPATH, "//*[@id=\"page-wrapper\"]/div[2]/div[2]/center/form/div/label[2]")
but the value returned in codes
is:
<selenium.webdriver.remote.webelement.WebElement (session="ae4e91d8ec7e2bc161", element="0.570523580858733-2")
Can anyone suggest a way to do this?