wdio 异步调用在调用 promise 调用时丢弃 Selenium 连接
wdio async call drops the Selenium connection when invokes a promise call
版本:“webdriverio”:“^5.7.5”,
如果我不清楚,请提前致歉,请让我知道并相应地传递我的意见。
我是 运行 我的公司代理背后的 wdio5 脚本。它在所有浏览器上成功运行。我尝试将 api 调用集成到框架中并开始遇到多个问题。
Api supertest、axios [包括 httpsProxyAgent]、sync-request、then-request 等库不读取 wdio 使用的 npm 代理变量。因此,我在 API 调用
时收到以下错误消息
Error: getaddrinfo ENOTFOUND qa.internalurl.co.uk
qa.internalurl.co.uk:443
Api 库,例如 -request、fetch-with-proxy 使用代理设置成功调用 API。我需要“等待”他们的回应,因此将我的 it 块移动为异步函数。但是在作为异步调用成功响应后,我收到以下错误消息
[chrome #0-0] $(...).waitForExist is not a function
[chrome #0-0] TypeError: $(...).waitForExist is not a function
不只是 waitForExist,会话几乎无法记住任何 selenium/webdriverio 命令。很明显,当它切换到异步调用以获取 promise 响应时,它正在失去 selenium 连接。
有办法解决吗?
let accountNo = "123456";
it.only('verify the dashboard page ',async () => {
//launches the browser url and cleans the cookies
try {
response = await apiCheck.postApiLoginData(accountNo);
//Makes to call to API function to get the values
} catch (err) {
console.error(err);
}
console.log(response); //prints the successful response data
lPage.enterLoginData(accountNo, 'pass1234'); //Fails here as the data is
addStep(`Login to the Standard application using username as ${accountNo} and PIN as 74437`);
lPage.assertSummaryPage(response);
}
没有 Try 块代码,成功登录到应用程序。
要处理非 wdio 异步代码,您需要使用 the browser.call
function。例如:
response = browser.call(() => {
return apiCheck.postApiLoginData(accountNo);
//Makes to call to API function to get the values
})
版本:“webdriverio”:“^5.7.5”,
如果我不清楚,请提前致歉,请让我知道并相应地传递我的意见。
我是 运行 我的公司代理背后的 wdio5 脚本。它在所有浏览器上成功运行。我尝试将 api 调用集成到框架中并开始遇到多个问题。
Api supertest、axios [包括 httpsProxyAgent]、sync-request、then-request 等库不读取 wdio 使用的 npm 代理变量。因此,我在 API 调用
时收到以下错误消息Error: getaddrinfo ENOTFOUND qa.internalurl.co.uk qa.internalurl.co.uk:443
Api 库,例如 -request、fetch-with-proxy 使用代理设置成功调用 API。我需要“等待”他们的回应,因此将我的 it 块移动为异步函数。但是在作为异步调用成功响应后,我收到以下错误消息
[chrome #0-0] $(...).waitForExist is not a function
[chrome #0-0] TypeError: $(...).waitForExist is not a function
不只是 waitForExist,会话几乎无法记住任何 selenium/webdriverio 命令。很明显,当它切换到异步调用以获取 promise 响应时,它正在失去 selenium 连接。
有办法解决吗?
let accountNo = "123456";
it.only('verify the dashboard page ',async () => {
//launches the browser url and cleans the cookies
try {
response = await apiCheck.postApiLoginData(accountNo);
//Makes to call to API function to get the values
} catch (err) {
console.error(err);
}
console.log(response); //prints the successful response data
lPage.enterLoginData(accountNo, 'pass1234'); //Fails here as the data is
addStep(`Login to the Standard application using username as ${accountNo} and PIN as 74437`);
lPage.assertSummaryPage(response);
}
没有 Try 块代码,成功登录到应用程序。
要处理非 wdio 异步代码,您需要使用 the browser.call
function。例如:
response = browser.call(() => {
return apiCheck.postApiLoginData(accountNo);
//Makes to call to API function to get the values
})