I am using Robot framework to automate a file upload to a webpage. I am using the Choose File keyword.
Code notes: ${CONTINUE_BUTTON} is a button at the bottom of the screen, ensuring that the entire bottom of the webpage is visible. The Sleeps are there temporarily so that I know it’s not a timing issue and can watch the automation as it happens.
”’
${uploadFileButton} = xpath://*[@id="67e21641-340b-4f15-94e2-e5ab7a8532a1"]/div/button
${testDoc} = C:UsersjasonbDocumentsDummyDocumentsTestDocument.pdf
Scroll Element Into View ${CONTINUE_BUTTON}
Sleep 10s
Wait Until Element Is Visible ${uploadFileButton}
Choose File ${uploadFileButton} ${testDoc}
Sleep 10s
”’
I ensured that the Xpath locator is the correct one by searching it in my inspect panel. In the failure screenshots, the button is visible.
When I use the Wait Until Element Is Visible keyword, I get this error:
”’
Element 'xpath://*[@id="67e21641-340b-4f15-94e2-e5ab7a8532a1"]/div/button' not visible
after 5 seconds.
”’
When I don’t use the Wait Until Element is Visible keyword, I get this error:
”’
Element with locator 'xpath://*[@id="67e21641-340b-4f15-94e2-e5ab7a8532a1"]/div/button'
not found.
”’
I also tried using a different element that is not the clickable part of the upload file button:
”’
${uploadFileButton} = xpath://*[@id="67e21641-340b-4f15-94e2-e5ab7a8532a1"]/div/button
”’
And got this error:
”’
Element with locator 'xpath://*[@id="67e21641-340b-4f15-94e2-e5ab7a8532a1"]' not
interactable.
”’
So it can see the non-clickable element, but not the clickable element just a few HTML lines down from it. What is happening here?
Source: Read More