It seems that it cannot be taken. You can't "scroll to this element" because you can't get it in the first place. I swiped properly when I did it, but I don't know the correct (stable) method.
I was able to get it with findElement type functions until a while ago, but now it looks like this
python
appiumDriver.switchTo().alert().accept();
//appiumDriver is an instance of AppiumDriver
When displaying the screen with Webview or displaying the screen based on the information from the network, the loading may not be completed by the timeout. You can add weights normally, but if you try again several times, you can save some time. But usually you should think about why it's so heavy.
python
/*
*A function that just squeezes the sleep exception
*/
static public void sleep(int millis) {
try {
Thread.sleep(millis);
} catch (Exception e) {
//Since it is just a weight, the exception is to put out only the stack trace and squeeze it appropriately.
e.printStackTrace();
}
}
/**
* try find element /retry/ times.
* @param by
* @param retry
* @return
*/
public WebElement findElementByXPathSometime(final String by, final int retry){
int count;
RuntimeException ex=null;
WebElement elem;
for(count = 1;count<=retry;count++) {
try {
logger.debug("try to get element : " + by.toString());
//log4j logger
elem = appiumDriver.findElementByXPath(by);
//appiumDriver is an instance of AppiumDriver
return elem;
}catch(RuntimeException e) {
ex = e;
logger.debug("failed to get element");
sleep(5000);
}
}
There is an element that WebElement # click ()
does not respond to. Maybe it doesn't respond to the elements in Webview, so do the following:
python
WebElement element = findElementByXPathSometime(AppElements.SETTING,20);
new TouchAction(appiumDriver).tap(element).perform();
//appiumDriver is an instance of AppiumDriver
This was no longer possible. For some reason, I can't find the element with ʻAppiumDriver # findElementBy Hogehoge ()`.
python
(new TouchAction(appiumDriver)).tap(123, 456).perform();
//Forcibly tap the text box
sleep(1000);
appiumDriver.getKeyboard().pressKey("nyuuryokusitaimoziretu");
Note that ʻAppiumDriver # getKeyboard ()` fails because the soft keyboard does not appear when the hard keyboard is enabled in the iOS simulator. inconvenience.
Recommended Posts