I am encountering a perplexing issue with XPath evaluation in the context of SelenideAppium for an iOS application. A direct XPath query executes and retrieves the value as expected, but when I attempt to replicate the query by chaining calls on a SelenideAppiumElement, the result isn't the same.
The following direct XPath call retrieves the value successfully:
$x("//XCUIElementTypeStaticText[@name='"+accountName+"']/following-sibling::XCUIElementTypeStaticText[1]").getValue()
However, the same logic, when applied using a SelenideAppiumElement obtained from a utility method in our framework, does not return the expected value:
Variant 1:
SelenideAppiumElement accountNameElement = BaseUtils.findElementByTagName(accountName);
accountNameElement.$x("./following-sibling::XCUIElementTypeStaticText[1]").getValue()
Variant 2:
SelenideAppiumElement accountNameElement = BaseUtils.findElementByTagName(accountName);
accountNameElement.sibling(0).getValue()
For some reason, neither Variant 1 nor Variant 2 returns the value I obtain with the direct XPath call. The findElementByTagName method is supposed to return a SelenideAppiumElement corresponding to the specified tag name, which in turn should allow for further traversal using XPath. I only get Method threw 'com.codeborne.selenide.ex.ElementNotFound' exception.
I'm looking for insights into why chaining calls on the SelenideAppiumElement does not yield the same result as the direct XPath query. Has anyone else faced this issue or can offer some advice on what might be going wrong?
This is the method findELementByTagName
public static SelenideAppiumElement findElementByTagName(String tagName) {
return $(AppiumBy.name(tagName));
}