Apply @WithTimeout annotation for @FindAll annotation

94 views
Skip to first unread message

Dani

unread,
Apr 6, 2022, 7:28:49 AM4/6/22
to Selenium Users
Hi!
I found similar stackoverflow, github posts, but the only real answer was to use xpath with logical OR (|) expression, but I would prefer one of my suggestions below.

Short example:
Lets say I have a skip button on screen. Swiping left on the screen displays new screens, and when I reach the last screen, that skip button becomes a close button.
In my framework I want to test cross-platform iOS and Android apps.
On iOS I have the same locator on every screen, but on android, the last screen's button has different id.
My goal is to identify an element by id one of the given ids, meaning the other one will not be on the screen, so the implicit wait will pass until the close button is found with the second given id.
Here comes my problem. 

@iOSXCUITFindBy(accessibility = "skipCloseId")
@AndroidFindAll({
      @AndroidBy(id = "skipId"),
      @AndroidBy(id = "closeId")
})
private WebElement skipButton;



I suggest one of these:

- Create a new annotations: FindAny, AndroidFindAny, iOSXCUITFindAny.
In this case, the given it should be a quick lookup, if are there any matches, and if yes, return the first found without  applying any implicit wait for the not found locators. (If no element found, then apply implicit wait until the first found).

@AndroidFindAny({
      @AndroidBy(id = "skipId"),
      @AndroidBy(id = "closeId")
})
private WebElement skipButton;


- Allow using @WithTimeout annotation for @FindAll, @AndroidFindAll, @iOSXCUITFindAll annotations.
The @WithTimeout is working as expected for @AndroidFindBy. I can overwrite the implicit wait of the driver, and set a custom timeout for waiting.
However if I apply @WithTimeout for @AndroidFindAll it doesn't give me any error, but the custom @WithTimeout does not take effect. In this case the expected behaviour could be that the implicit wait for element lookup should be the custom @WithTimeout value.

@WithTimeout(time = 0, chronoUnit = ChronoUnit.SECONDS)
@AndroidFindAll({
      @AndroidBy(id = "skipId"),
      @AndroidBy(id = "closeId")
})
private WebElement skipButton;






Reply all
Reply to author
Forward
0 new messages