I'm trying to get to "input" so that I can enter the values, knowing that the value of the ID is constantly changing
<div>
<idms-error-wrapper {^error-type}="errorType" {^idms-error-wrapper-classes}="idmsErrorWrapperClasses"
<div >
<input errors="{errors}" {^has-errors}="hasErrors" {$value}="value"
{$aria-required}="isRequired" type="text"
id="input-1647425309700-0" value="" aria-required="true">
</div>
</idms-error-wrapper>
</div>
CodePudding user response:
In case 1647425309700
or 1647425309700-0
is variable here you can use something like this:
input_id = 1647425309700
input_xpath = "//input[contains(@id,'" str(input_id) "')]"
driver.find_element(By.XPATH,input_xpath)
CodePudding user response:
The <id>
attribute of the <input>
tag, i.e. input-1647425309700-0
is dynamically generated and will change everytime you would access the page afresh. So identify the desired element you can use either of the the following locator strategies:
css_selector:
input.form-cell.form-textbox.form-textbox-text.form-field[id^='input'][aria-required='true'][value]
xpath:
//input[@class='form-cell form-textbox form-textbox-text form-field' and starts-with(@id, 'input')][@aria-required='true' and @value]
Reference
You can find a relevant detailed discussion in: