Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Element-wait plugin not retrying when element not found #117

Open
rimeak opened this issue Apr 29, 2024 · 5 comments
Open

Element-wait plugin not retrying when element not found #117

rimeak opened this issue Apr 29, 2024 · 5 comments

Comments

@rimeak
Copy link

rimeak commented Apr 29, 2024

I'm using the element-wait plugin with Robot Framework and Appium2 to automate mobile testing. I've created a configuration file .appiumrc.json with the following settings:
{
"server": {
"plugin": {
"element-wait": {
"timeout": 2000000,
"intervalBetweenAttempts": 200,
"excludeEnabledCheck": ["click", "false"]
}
},
"use-plugins": ["element-wait"]
}
}
When executing tests, the Appium server starts with the plugin, and the timeout and interval settings are correctly applied. However, when attempting to find an element using the AppiumDriver.findElements() method, if the element is not found on the first attempt, the test immediately fails without retrying.

I expected the plugin to retry finding the element based on the configured timeout and interval settings, similar to how the Wait Until Page Contains Element keyword works in Robot Framework. However, it seems that the plugin is not retrying the element search.

Steps to Reproduce:

Set up Appium server with the element-wait plugin configured as described above.
Write a test case to find an element that may not be immediately available.
Execute the test case and observe that the test fails without retrying the element search.
Environment:

Operating System: Windows
Appium Version: 2.5.1
Device Under Test: android emulator

Expected Behavior:
I expect the element-wait plugin to retry finding the element according to the configured timeout and interval settings, allowing for more robust and reliable element detection during test execution.

@rimeak
Copy link
Author

rimeak commented Apr 29, 2024

@saikrishna321
Copy link
Member

@rimeak if the element is not found on the first attempt, the test immediately fails without retrying I don't see any failures in the logs.

@rimeak
Copy link
Author

rimeak commented Apr 30, 2024

The test begins by establishing a session through a POST request to the /session endpoint. Following this, it proceeds to navigate to a designated URL using a POST request to /session/b4b308f3-e53e-4ef6-b135-33f4cdb9410e/url, with the URL provided in the request body.

Upon reaching the specified URL, the test initiates the search for elements on the page by sending a POST request to /session/b4b308f3-e53e-4ef6-b135-33f4cdb9410e/elements, accompanied by the XPath query. Upon successful execution, the response typically contains the ID of the element in the "value" field : Got response with status 200: {"sessionId":"403e3d02-7387-455e-9284-54cb0f01af9c","value":[{"ELEMENT":"00000000-0000-0023-ffff-ffff00000012","element-6066-11e4-a52e-4f735466cecf":"00000000-0000-0023-ffff-ffff00000012"}]}

During the execution flow, the test successfully locates and interacts with the second element identified by the XPath query //android.widget.Button[@resource-id="com.android.chrome:id/negative_button"], as the response contains the ID of the element.

However, when attempting to locate the third element using the XPath query //android.widget.Button[@resource-id="details-button"], the response returns with an empty "value" field : Got response with status 200: {"sessionId":"403e3d02-7387-455e-9284-54cb0f01af9c","value":[]}. This implies that the element may not have been fully loaded on the page at the time of the request, preventing the test from clicking it. Consequently, the test fails, and a screenshot is captured.

I've ensured that the locators are correctly defined, and when utilizing the "wait until page contains element" keyword before each click action, the test successfully retries until the element is found. I anticipated that the plugin would exhibit similar retry behavior, persistently attempting to locate the element within the specified timeout of 300000 milliseconds and an interval between attempts of 60000 milliseconds. However, it appears that the plugin does not retry the element lookup as expected, the test fails on the first attempt if the element is not found within the timeout period.

see pic below for fail when executing test with element-wait plugin
fail for github

@rimeak rimeak closed this as completed May 2, 2024
@rimeak rimeak reopened this May 2, 2024
@saikrishna321
Copy link
Member

@rimeak is it possible to give a sample project to reproduce this issue ?

@rimeak
Copy link
Author

rimeak commented May 3, 2024

Sure @saikrishna321, here is a sample project :
SampleProjetc.zip
here is what i got in my case :
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants