0

Trying to locate an input element which seems to actually have a dynamic property of the input element. This input is inside a td and displays Success or Failure on the webpage and is alongside the text Completion Code. Ive tried xpath and id to find the input element but I am getting "unable to locate element" Once I have that first step above, then I want to pull what is in the value field, which is actually the text displayed on the webpage beside Completion Code. For example

Completion Code Success

My code -

completion_code = driver.find_element(By.XPATH, '//*[@id="code"]')
print(completion_code.text)

The html

<tr>
   <td id="label.code" class="label" type="string" choice="0" height="23px" nowrap="true">
   <label onclick="" for="code" dir="ltr" class="  control-label"><span id="status." mandatory="false" oclass="" aria-label="" class=" required-marker"></span>
   <span class="label-text" data-html="false">Completion code</span>
   </label>
</td>
   <td style="background-color:PaleGreen;width:100%;;" nowrap="true">
   <input autocomplete="off" autocorrect="off" readonly="readonly" name="code" id="code" value="Success" onkeyup="" onchange="onChange('code');" size="" style="border:0px;background:transparent" maxlength="" type="text">
   </td>
</tr>

3

1 Answer 1

0

Ok, well it turns out I presumed the wait wasn't a factor it was, added that and the following got the value from the input box which shows the required results

 transform_history = driver.find_element_by_name("code")     
 print(transform_history.get_attribute('value'))
Sign up to request clarification or add additional context in comments.

1 Comment

String dataID = transform_history.GetAttribute('id'); is what you are looking for from the your question. @anfield i think.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.