Appium iOS Safari Open new tab, accept alerts and switch between two tabs

走远了吗. 提交于 2019-12-08 11:23:07

问题


So I'm testing a web app for which I have to open a new tab, switch to it, do some input, than switch back to the first tab and this more than once. I try to open the new tab this way:

((JavascriptExecutor) AppiumTestBase.getDriver()).executeScript("window.open('http://google.com', '_blank')");

This causes the following alert to appear:

But I'm not able to accept it through automation with Appium. Things that I have tried:

  • Using the following capabilities: "safariAllowPopups" and "autoAcceptAlerts"
  • Changing the according settings for safari in the iOS sim
  • .switchTo().alert().accept(); I also waited for the Popup.
  • Switchting to native context before accepting the popup
  • Clicking the pop up by name .findElement(By.name("Allow")).click();

What I have not tried:

  • Taping on the screen according to the pop-up coordinates. I didn't try this since I'm not sure on how to get the position of the "Allow" button.

And my other question is how would I switch between two tabs? I haven't tried anything yet, but research would suggest that I try it with window contexts.

Some other information:

  • Currently testing with a iPhoneSE iOS 9.3 Simulator, the solution should work for several configurations
  • Appium is on the most recent version
  • The class "AppiumTestBase"s only purpose is to set capabilities and initialize the AppiumDriver

回答1:


Please try this cap after i change to this no popup from safari anymore

desired_capabilities=automationName:XCUITest,browserName:safari,platformName:iOS,platformVersion:11.1,deviceName:iPhone 6,nativeWebTap:True,safariIngoreFraudWarning:True



回答2:


I tried the solution suggested by Atthaboon Sanurt, but it didn't help. There was no alert, but the new window/tab didn't open either.

Here where the problem is reported: https://github.com/appium/appium/issues/6864

So far it looks like there is no solution and plans to fix it.



来源:https://stackoverflow.com/questions/47867759/appium-ios-safari-open-new-tab-accept-alerts-and-switch-between-two-tabs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!