mirror of
https://github.com/ARM-software/workload-automation.git
synced 2025-02-21 20:38:57 +00:00
Improve logic for scrolling during book search
This commit is contained in:
parent
14924ec6f4
commit
52d4635fe8
Binary file not shown.
@ -171,36 +171,19 @@ public class UiAutomation extends UxPerfUiAutomation {
|
|||||||
// book that contains a "free" or "purchased" book identifier
|
// book that contains a "free" or "purchased" book identifier
|
||||||
UiSelector bookSelector = new UiSelector().description(desc).className("android.widget.TextView");
|
UiSelector bookSelector = new UiSelector().description(desc).className("android.widget.TextView");
|
||||||
|
|
||||||
UiObject freeLabel =
|
UiObject label =
|
||||||
new UiObject(new UiSelector().fromParent(bookSelector)
|
new UiObject(new UiSelector().fromParent(bookSelector)
|
||||||
.resourceId("com.android.vending:id/li_label")
|
.resourceId("com.android.vending:id/li_label")
|
||||||
.description("Free"));
|
.descriptionMatches("^(Purchased|Free)$"));
|
||||||
|
|
||||||
UiObject purchasedLabel =
|
|
||||||
new UiObject(new UiSelector().fromParent(bookSelector)
|
|
||||||
.resourceId("com.android.vending:id/li_label")
|
|
||||||
.description("Purchased"));
|
|
||||||
|
|
||||||
UiScrollable searchResultsList =
|
UiScrollable searchResultsList =
|
||||||
new UiScrollable(new UiSelector().resourceId("com.android.vending:id/search_results_list"));
|
new UiScrollable(new UiSelector().resourceId("com.android.vending:id/search_results_list"));
|
||||||
|
|
||||||
int maxSwipes = 10;
|
searchResultsList.scrollIntoView(label);
|
||||||
while (!freeLabel.exists() && !purchasedLabel.exists()) {
|
|
||||||
if (maxSwipes <= 0) {
|
|
||||||
throw new UiObjectNotFoundException("Could not find free or purchased book \"" + bookTitle + "\"");
|
|
||||||
} else {
|
|
||||||
searchResultsList.swipeUp(100);
|
|
||||||
maxSwipes--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Click on either the first "free" or "purchased" book found that
|
// Click on either the first "free" or "purchased" book found that
|
||||||
// matches the book title
|
// matches the book title
|
||||||
try {
|
label.click();
|
||||||
freeLabel.click();
|
|
||||||
} catch (UiObjectNotFoundException e) {
|
|
||||||
purchasedLabel.click();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addToLibrary() throws Exception {
|
private void addToLibrary() throws Exception {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user