[Arguments] ${card_name}
Wait Until Element Is Visible ${loc} ${short_time}
@{Locators_common} = Get WebElements ${loc_}
Click Element ${Locators_common}[${card_name}]
Wait Until Element Is Visible ${loc_Validation} ${short_time}
hi i am new at robot framework
i want to used element from locator_common list on the basic of their index so
when i used click element and pass ${Locators_common}[${card_name}] that time ElementNotInteractableExceptionexcepation showd ho to deal it ?
Error your receiving is thrown to indicate that although an element is present on the HTML DOM, (which would suggest the locator looks to be valid) but it suggests it is not in a state that can be interacted with. And the âWait Until Element Is Visibleâ is a good start and should normally resolve the issue in most, could you confirm if the element youâre wanting to âClickâ is out of view on load? as you may have to scroll this into view before interacting with it, this can be achieved with the below as something to try
SeleniumLibrary: Scroll Element Into View ${Locators_common}[${card_name}]
You could wrap that in [Run Keyword And Ignore Error ] which is part of the built-in library, depending on your error handling
But in terms of fully understanding where the issue may be sharing the log for where itâs falling over and possibly a snippet of the dom for the element youâre trying to click, could be helpful in helping you if the above doesnât resolve where the exception is thrown.
thanks
but after used Scroll Element Into View ${Locators_common}[${card_name}]
same exception will showed ElementNotInteractableException: Message: element not interactable:
â Are you able to provide a snippet of the dom and RF logs for where itâs falling over, if itâs a public site then providing the Url and for which element youâre having trouble would be helpful as mentioned⌠â
But, Iâm almost certain the problem is this below in bold as it will be by index youâll need to use to return that item (element) from the list of elements, and then do some form of a check to make sure its the correct element you want to interact with, based on whatâs been given:
@{Locators_common} = Get WebElements ${loc_}
Click Element ${Locators_common}[${card_name}]
Hard not to guess when thereâs not much given but it will be a 0-based index, and not knowing what âcard_nameâ holds, could be 0+ or a string valueâŚ
I guess there are a number of things you could do, if all cards use the same/part locator + ${card_name} you can remove the line of @{Locators_common} = Get WebElements ${loc_} and then, set a common variable for ${cards_common}, then do the below:
Click Element ${cards_common}//*[@text='${card_name}']
Youâll just need to figure out what that common part is, the dom is a good place to figure out what that common XPath may look like.
You might use the [1] element which is the one visible and interactable.
The second one might be hidden and used/built for other purposes (other login type or frame not displayed currently)
However you didnât mentioned what fails ? I assume the âInput Textâ keyword ?
Verify in the upper levels of the xpath if the //input is not in an iframe or shadow-dom.
In the iframe case you should select it first to âenterâ the frame and interact with its content.
Then donât forget to Unselect Frame after to continue interaction after login.
For shadow-dom this would be more tricky depending of the used libraries.
Well itâs none of the ideas above, I went to your page thereâs no iframe nor shadow-dom.
I have it working with your xpath the first time in debug, but not the second timeâŚ
I donât really now why but sometimes the needed and interactable input is the [1] and sometimes the [2], and seems to switch randomly.
Finally I think youâll need the precise the xpath in a more accurate way⌠You might know better whatâs important for you, but this works :
Login Test
Open Browser https://i-fi.ai/login chrome
Maximize Browser Window
Input Text //div[contains(@class, 'visible-md visible-lg')]//input[@id='signInFormUsername'] TestingName
I only found a difference in the upper div with visible-md visible-lg attribute, and oddly both input have a hidden attribute.
Then if the attribute is not a strong solution enough, you could also use only one simple xpath in a try/except (even though itâs some kind of ugly workaround) :
TRY
Input Text (//input[@id='signInFormUsername'])[1] TestingName1
EXCEPT
Input Text (//input[@id='signInFormUsername'])[2] TestingName2
END