0
votes

I am writing an automation script for an avatar upload module with the following CSS locator:

input[accept="image/png,image/jpeg,image/gif,image/bmp"]

I am using Robot Framework's Wait Until Element Is Visible keyword to look for the locator above but is unsuccessful with the error:

Element 'css=input[accept="image/png,image/jpeg,image/gif,image/bmp"]' not visible after 30 seconds.

Increasing the timeout also doesn't work. Using the same in Chrome Dev Tools would successfully find the element. My guess is that the commas/slashes are messing with Robot's locator parsing. My question is: What is the correct way to write the locator?

2
The content of the locator is used as is, RF doesn't have any issues with the commas or the slashes. It should be something else - the element is shown after some interaction, or it is simply not visible, just present - a more "stylized" span or div is what the user sees. Try with Page Should Contain Element.Todor Minakov
@Todor I changed the validation to use the keyword Wait Until Page Contains Element and it worked! It looks like Selenium/Robot recognizes input tags that are not text fields as not visible even though they appear in the DOM.jeffsia

2 Answers

2
votes

Though present in the DOM, an element may not be visible/rendered. This is very often the case with file upload input elements - the UI renders something different, a button, div that had applied styling and fits in better with the overall design.

Thus a check is it visible will rightfully fail. Change your pre-usage approach to validate the input is in the HTML - this is actually the same as what you did in the browser's dev tools - with the Page Should Contain Element keyword, and proceed on success.

0
votes

There is no problem with the CSS locator your are using. Maybe the element is in another iframe?