Appium iOS Safari打开新选项卡,接受警报并在两个选项卡之间切换 [英] Appium iOS Safari Open new tab, accept alerts and switch between two tabs

查看:306
本文介绍了Appium iOS Safari打开新选项卡,接受警报并在两个选项卡之间切换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我正在测试一个Web应用程序,为此,我必须打开一个新标签页,然后切换到该标签页并进行一些输入,然后再切换回第一个标签页,并且不止一次。
我尝试以这种方式打开新选项卡:

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:

但是我无法通过Appium的自动化来接受它。我尝试过的事情:

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


  • 使用以下功能: safariAllowPopups和 autoAcceptAlerts

  • 在iOS sim卡中更改野生动物园的相应设置

  • .switchTo()。alert()。accept();我也等待着弹出窗口。

  • 在接受弹出窗口之前切换到本地上下文

  • 单击名称为.findElement(By.name( 允许))。click();

  • 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();

我没有尝试过的东西:


  • 根据弹出坐标在屏幕上键入。我没有尝试此操作,因为不确定如何获得允许按钮的位置。

另一个问题是如何在两个标签之间切换?我还没有尝试过任何东西,但是研究表明我可以在窗口上下文中尝试它。

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.

其他一些信息:


  • 当前正在使用iPhoneSE iOS 9.3模拟器进行测试,该解决方案应适用于多种配置

  • Appium是最新版本

  • AppiumTestBase类的唯一目的是设置功能并初始化AppiumDriver

推荐答案

在我从野生动物园更改为不再弹出后,请尝试使用此上限

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

这篇关于Appium iOS Safari打开新选项卡,接受警报并在两个选项卡之间切换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆