For static otp verification code(For ex. 1234), xpath of the Linear layout textbox element (verification code) is not found and getting error that “xpath not found”.
Initially user name and password is given and after clicking on sign in, it navigates to this screen and asking for OTP verification code. Here its a linear layout textbox with four inputs for verification code.
while writing robot script with keyword ‘Input Text’ using xpath of the textbox, the element is not found.
Need any suggestion to overcome this error.
Here I have attached the screenshot of the webpage.
Always a good idea to show what you have tried, you said you got “xpath not found" but didn’t show which xpath that was for?
here is the xpaths I would use as a first try:
(//input[@type="tel" and @maxlength="1"])[1]
(//input[@type="tel" and @maxlength="1"])[2]
(//input[@type="tel" and @maxlength="1"])[3]
(//input[@type="tel" and @maxlength="1"])[4]
the combination of type=tel and maxlength=1 is probably unique to these 4 fields, so that should get you to those fields and then it’s just a matter of selecting which one you want.
Input Text xpath=//[@id=“root”]/div/div[1]/div[2]/div/div[1]/div/div[2]/div/div[1]/div/div[1]/input 1
Input Text xpath=//[@id=“root”]/div/div[1]/div[2]/div/div[1]/div/div[2]/div/div[1]/div/div[2]/input 2
Input Text xpath=//[@id=“root”]/div/div[1]/div[2]/div/div[1]/div/div[2]/div/div[1]/div/div[3]/input 3
Input Text xpath=//[@id=“root”]/div/div[1]/div[2]/div/div[1]/div/div[2]/div/div[1]/div/div[4]/input 4
Thanks for your xpath suggesstion. here are the one i used for my robot framework
Input Text xpath=//[@id=“root”]/div/div[1]/div[2]/div/div[1]/div/div[2]/div/div[1]/div/div[1]/input 1
Input Text xpath=//[@id=“root”]/div/div[1]/div[2]/div/div[1]/div/div[2]/div/div[1]/div/div[2]/input 2
Input Text xpath=//[@id=“root”]/div/div[1]/div[2]/div/div[1]/div/div[2]/div/div[1]/div/div[3]/input 3
Input Text xpath=//[@id=“root”]/div/div[1]/div[2]/div/div[1]/div/div[2]/div/div[1]/div/div[4]/input 4
InvalidSelectorException: Message: invalid selector: Unable to locate an element with the xpath expression //input[@type=“tel” and @maxlength=“1”])[1] because of the following error:
SyntaxError: Failed to execute ‘evaluate’ on ‘Document’: The string ‘//input[@type=“tel” and @maxlength=“1”])[1]’ is not a valid XPath expression.
Input Text xpath=//input[@type="tel" and @maxlength="1"])[1] 1
Input Text xpath=//input[@type="tel" and @maxlength="1"])[2] 2
Input Text xpath=//input[@type="tel" and @maxlength="1"])[3] 3
Input Text xpath=//input[@type="tel" and @maxlength="1"])[4] 4
Input Text xpath:(//input[@type="tel" and @maxlength="1"])[1] 1
Input Text xpath:(//input[@type="tel" and @maxlength="1"])[2] 2
Input Text xpath:(//input[@type="tel" and @maxlength="1"])[3] 3
Input Text xpath:(//input[@type="tel" and @maxlength="1"])[4] 4
Input Text (//input[@type="tel" and @maxlength="1"])[1] 1
Input Text (//input[@type="tel" and @maxlength="1"])[2] 2
Input Text (//input[@type="tel" and @maxlength="1"])[3] 3
Input Text (//input[@type="tel" and @maxlength="1"])[4] 4
That’s weird can you check the xpath outside RF, in the dev tools screen in your screen shot you should be able to click the element then do a find (control-f or command-f on mac) and past the xpath I gave you into the search field to check it.
also check the double quotes are actually double quotes and not some other character, the ones in your reply are not " but “.
It is a different thing what you observe with your eyes compared how automation works you might be searching for element before dom has been updated with the new information.
Have you tried to use Wait Until Element Is visible (//input[@type=“tel” and @maxlength=“1”])[1] before actually using Input Text ?
And you could be locating the button with something like… //button[text()=“VERIFY”] ← verify might be written in different ways, I mean css could change the appearance of the text so look into inspector how it is written