Keyword Issue in Get Element count

Hi all, I’m using RPA.Browser.Playwright in my robocorp VS.code environment. I need to proceed the Try block if i found a element or else I need to execute if i found another element in, so i used Get Element Count in my code, now the issue is it need to return the count of element if element is found but it returns zero. i don’t know why this issue happens
i used get element count like
${count} Get Element Count xpath
Try
If ${count} > 0

Try
Get Element Count xpath > 0
I used both this syntax but im getting zero if the element also present

other keywords like wait for element state waits foe 10sec or the timeout we gave in try block and then proceed to except, I need to avoid the extra time

If Get Element Count returns zero it means there are no matches to your xpath

yeah I know that, issue is there is a element in that page which matches the xpath.
Im using RPA.Browser.Playwright so i didn’t give any sleep for page to load is that maybe a problem

You also need to consider that you element might be inside iframe or shadow-root. In that case you need adjust playwright selector accordingly.

1 Like

ok, will look into it

Hi is that issue resloved ?
I’m trying to get a number element count and save the count value in a variable ${count} for later use in the code, but it shows zero, it’s not saving the value, using RPA.Playwright.Browser, Get Element Count, is there any way to do it?

Hello,
There is no known “issue” with the keyword. To get the elements you need to make sure that your selector is valid. You also need to validate the existence of iframes and shadow-roots.

1 Like

sorry, Can you give a example code for that. And how to validate iframes and shadow roots

There is information on the documentation

And you can also use https://chat.robocorp.com/