I need to locate and input text into the text field with the following HTML with Selenium:
<input slot="input" id="abc-gib-input-38303-70ft6l7k2g" aria-invalid="false" aria-required="true" aria-labelledby="label-abc-gib-input-38303-70ft6l7k2g label-abc-form-38302-42pti7lz8z" aria-describedby="help-text-abc-gib-input-38303-70ft6l7k2g feedback-abc-gib-input-38303-70ft6l7k2g feedback-abc-form-38302-42pti7lz8z help-text-abc-form-38302-42pti7lz8z" type="text" placeholder="" name="login" autocomplete="off">
The problem is each time page reloads the id changes - this part remains the same "abc-gib-input-38303-".
How to select this element?
I tried:
await driver.findElement(By.xpath('//*[contains(@id,"abc-gib-input"]'))
and it does not work.
CodePudding user response:
You are missing a closing bracket ) in your XPath expression.
Instead of
await driver.findElement(By.xpath('//*[contains(@id,"abc-gib-input"]'))
It should be
await driver.findElement(By.xpath('//*[contains(@id,"abc-gib-input")]'))
