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

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

问题描述

所以我正在测试一个网络应用程序,我必须打开一个新选项卡,切换到它,做一些输入,然后切换回第一个选项卡,这不止一次.我尝试以这种方式打开新标签:

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 中更改 safari 的相应设置
  • .switchTo().alert().accept();我也在等待弹出窗口.
  • 在接受弹出窗口之前切换到本机上下文
  • 按名称单击弹出窗口 .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

推荐答案

在我从 safari 改成这个 no popup 后,请试试这个上限

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天全站免登陆