运行 在 BrowserStack 上使用 nightwatch 自动化脚本时如何关闭 safari 弹出对话框?
How to close the safari pop up dialogue when running automate script with nightwatch on BrowserStack?
我使用Browserstack做E2E测试,现在我尝试运行浏览器stack上safari中的移动自动脚本时遇到问题,当我点击一个时会有弹出对话框显示按钮将导致打开一个新选项卡,对话框显示如下消息:'this site is attempting to open a popup window',我必须关闭它,脚本才能继续执行。
现在的问题是:
1. 当我点击触发这个弹出对话框的按钮时,日志中总是显示异常:'Error while running .clickElement() protocol action: Appium error: An unknown server-side error occurred while processing the command. Original error: Did not get any response after 20s'。
2.我可以用XPath在弹出的对话框中找到按钮并点击它关闭对话框,但是需要几分钟,有没有其他方法可以更有效地完成这个操作?
const { client } = require('nightwatch-api')
const { Given, Then, When} = require('cucumber')
Given('open mobile 163 news', async function () {
await client.url('https://3g.163.com/news/article/EJN99AOF000189FH.html?clickfrom=index2018_news_newslist#offset=0')
})
When('choose share by QQ', async function () {
await client.waitForElementVisible('.sharelogo')
await client.click('.sharelogo')
})
Then('the popup should show', async function () {
await client.waitForElementVisible('.qzone')
await client.click('.qzone')
await client.setContext('NATIVE_APP')
await client.source(function(res){
console.log(res.value)
})
await client.useXpath()
await client.click('//*[@name="Allow"]')
await client.contexts(function(result) {
client.setContext(result.value[result.value.length - 1])
client.useCss()
})
})
您是否尝试过添加功能 'nativeWebTap' 并将其设置为测试脚本中的值 'true'?
我使用Browserstack做E2E测试,现在我尝试运行浏览器stack上safari中的移动自动脚本时遇到问题,当我点击一个时会有弹出对话框显示按钮将导致打开一个新选项卡,对话框显示如下消息:'this site is attempting to open a popup window',我必须关闭它,脚本才能继续执行。
现在的问题是: 1. 当我点击触发这个弹出对话框的按钮时,日志中总是显示异常:'Error while running .clickElement() protocol action: Appium error: An unknown server-side error occurred while processing the command. Original error: Did not get any response after 20s'。 2.我可以用XPath在弹出的对话框中找到按钮并点击它关闭对话框,但是需要几分钟,有没有其他方法可以更有效地完成这个操作?
const { client } = require('nightwatch-api')
const { Given, Then, When} = require('cucumber')
Given('open mobile 163 news', async function () {
await client.url('https://3g.163.com/news/article/EJN99AOF000189FH.html?clickfrom=index2018_news_newslist#offset=0')
})
When('choose share by QQ', async function () {
await client.waitForElementVisible('.sharelogo')
await client.click('.sharelogo')
})
Then('the popup should show', async function () {
await client.waitForElementVisible('.qzone')
await client.click('.qzone')
await client.setContext('NATIVE_APP')
await client.source(function(res){
console.log(res.value)
})
await client.useXpath()
await client.click('//*[@name="Allow"]')
await client.contexts(function(result) {
client.setContext(result.value[result.value.length - 1])
client.useCss()
})
})
您是否尝试过添加功能 'nativeWebTap' 并将其设置为测试脚本中的值 'true'?