Hi all,
I am trying to assert the text but variable is retrieving blank value hence assertion is failing .
as we see from your screenshot text of element empty (see text attribute ‘text’). so it is expected that empty text <> “Home”.
Thank you for info .
so how can i validate that i am landing on home page (.isDisplayed is working ) except .isDisplayed method is there any way to validate that i am landing on home page
You element has only id and content description equal to ‘Home’. You need just find element with this id or content description ‘Home’ and check that such element exist. It is enough in your case.
i am new to appium,can you please write the code so that i will refer the same code in future incase i find these kind of scenarios
// first way
List<MobileElement> homeElements = driver.findElements(MobileBy.id("Home"));
Assert.assertTrue(!homeElements.isEmpty(), "homeEl NOT found");
// second way
MobileElement homeElement = (MobileElement) driver.findElement(MobileBy.id("Home"));
boolean bool = false;
try {
bool = !homeElement.getId().isEmpty();
} catch (Exception e) {
}
Assert.assertTrue(bool, "homeEl NOT found");
Thank you so much for your support and code
first check that element found. second enable in developer menu option to show taps and check where actually tap happened if element found. third “not working” not clear - what exactly it means? no any actions?
i am trying to tab on first element using content-desc but its throwing error
error
An element could not be located on the page using the given search parameters.
For documentation on this error, please visit: https://www.seleniumhq.org/exceptions/no_such_element.html
so start first from fixing this e.g. try instead:
MobileElement el = (MobileElement) driver.findElement(MobileBy.AndroidUIAutomator("new UiSelector().descriptionContains(\"13Jan\"));"));
one quick question
why do we use mobileBy.AndroidUIAutomator, why not just AndroidUIAutomator,
just used to work with ’ MobileBy’. it is pure Appium -> https://appium.github.io/java-client/io/appium/java_client/MobileBy.html
i am getting this error for the above code
error
An element could not be located on the page using the given search parameters
is quick action (faster than 100ms). if element not found there are 2 reasons:
- search parameter is correct but element not appeared yet. e.g. needed screen with element not appeared.
- search parameter not correct.
First you may check by adding long sleep e.g. 10sec. Visually you can see that element appeared. Then search should found.
Other possibilities:
3.1) what is your appium server version?
3.2) java client version?
3.3) capabilities (hope UiAutomator2 for android → http://appium.io/docs/en/writing-running-appium/caps/)?
3.4) Android version on phone under test?
i am giving enough delay before finding description.
have also mentioned UIAutomator2 in capabilities
Versions
Appium v1.18.3
java version 1.8.0_271
Android version:10.0