MarketSquare / robotframework-browser

Robot Framework Browser library powered by Playwright.
Apache License 2.0
527 stars 106 forks source link

For "Get Element Count" keyword, combination "iframe selector >>> element selector inside a frame" throws an error, where it shouldn't #2795

Closed trybuskrzysztof closed 1 year ago

trybuskrzysztof commented 1 year ago

Describe the bug When using "Get Element Count" keyword, browser library throws an error when combination "iframe selector >>> element selector inside a frame" is not found.

To Reproduce As an example I used following steps: Get Element Count css=iframe >>> #privacy-modal == 1 Click css=iframe >>> #privacy-modal >> text="Allow All Cookies" Get Element Count css=iframe >>> #privacy-modal == 0

"Click" step closes an open iframe popup.

These steps pass: Get Element Count css=iframe >>> #privacy-modal == 1 Click css=iframe >>> #privacy-modal >> text="Allow All Cookies"

This step throws an error: Get Element Count css=iframe >>> #privacy-modal == 0

Error: locator.count: Error: failed to find frame for selector "css=iframe >> nth=0 >> internal:control=enter-frame >> #privacy-modal"
Traceback (most recent call last):
  File "C:\Python\lib\site-packages\Browser\playwright.py", line 160, in grpc_channel
    yield playwright_pb2_grpc.PlaywrightStub(self._channel)
  File "C:\Python\lib\site-packages\Browser\keywords\getters.py", line 616, in get_element_count
    response = stub.GetElementCount(
  File "C:\Python\lib\site-packages\grpc\_channel.py", line 1030, in __call__
    return _end_unary_response_blocking(state, call, False, None)
  File "C:\Python\lib\site-packages\grpc\_channel.py", line 910, in _end_unary_response_blocking
    raise _InactiveRpcError(state)  # pytype: disable=not-instantiable
grpc._channel._InactiveRpcError: <_InactiveRpcError of RPC that terminated with:
    status = StatusCode.RESOURCE_EXHAUSTED
    details = "Error: locator.count: Error: failed to find frame for selector "css=iframe >> nth=0 >> internal:control=enter-frame >> #privacy-modal""
    debug_error_string = "UNKNOWN:Error received from peer  {created_time:"2023-05-10T10:42:20.936351487+00:00", grpc_status:8, grpc_message:"Error: locator.count: Error: failed to find frame for selector \"css=iframe >> nth=0 >> internal:control=enter-frame >> #privacy-modal\""}"
>

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Python\lib\site-packages\Browser\browser.py", line 1122, in run_keyword
    raise e
  File "C:\Python\lib\site-packages\Browser\browser.py", line 1111, in run_keyword
    return DynamicCore.run_keyword(self, name, args, kwargs)
  File "C:\Python\lib\site-packages\robotlibcore.py", line 122, in run_keyword
    return self.keywords[name](*args, **(kwargs or {}))
  File "C:\Python\lib\site-packages\Browser\assertion_engine.py", line 62, in with_assertion_polling
    raise e
  File "C:\Python\lib\site-packages\Browser\assertion_engine.py", line 55, in with_assertion_polling
    return wrapped(*args, **kwargs)
  File "C:\Python\lib\site-packages\Browser\keywords\getters.py", line 622, in get_element_count
    return float_str_verify_assertion(
  File "C:\Python\lib\contextlib.py", line 131, in __exit__
    self.gen.throw(type, value, traceback)
  File "C:\Python\lib\site-packages\Browser\playwright.py", line 164, in grpc_channel
    raise AssertionError(error.details())
AssertionError: Error: locator.count: Error: failed to find frame for selector "css=iframe >> nth=0 >> internal:control=enter-frame >> #privacy-modal"

Expected behavior Step below should pass: Get Element Count css=iframe >>> #privacy-modal == 0

Desktop (please complete the following information):

Additional context All steps below pass, the problem occurs when trying to access an element inside iframe: Get Element Count css=iframe == 1 Click css=iframe >>> #privacy-modal >> text="Allow All Cookies" Get Element Count css=iframe == 0

aaltat commented 1 year ago

@allcontributors please add @trybuskrzysztof for bugs

allcontributors[bot] commented 1 year ago

@aaltat

I've put up a pull request to add @trybuskrzysztof! :tada:

aaltat commented 1 year ago

Would you have example page where one could reproduce the problem? If that is not available, could you show screenshots and explain what the Click actually does?

aaltat commented 1 year ago

I did try to reproduce the problem with this example: https://www.w3schools.com/howto/tryit.asp?filename=tryhow_css_modal and having it inside of a iframe. But I was not able to reproduce the problem and therefore I am not able to fix the problem.

Would it be possible for you to create example which I can run and it demonstrates the problem?

aaltat commented 1 year ago

Also could you try to with latest release, does the problem persist

Snooz82 commented 1 year ago

i think the problem is simple that the frame can not be found and the keyword does not return the count 0 but trows the error.

Will be fixed by #2917