I am using webdriver.io and Appium to test my apps on Android. I am hitting an issue regarding sessions in Chrome. When I login to a website and close Chrome and re-open it, I can see my session. When I do the same with Appium, it cleans all the sessions between app starts. I tried different options but none of them worked.
Here is the example workflow to login to a website and to open Chrome again.
const driver = await remote(
{
capabilities: {
'appium:waitForIdleTimeout': 100,
'appium:appPackage': 'com.android.chrome',
'appium:appActivity': 'com.google.android.apps.chrome.Main',
'appium:noReset': true,
'appium:fullReset': false,
'appium:allowTestPackages': true,
'appium:automationName': 'UiAutomator2',
'appium:deviceName': 'Android',
'appium:newCommandTimeout': 3600,
platformName: 'Android',
},
hostname: "localhost",
logLevel: "info",
port: 4723,
})
await driver.url('');
await driver.$(`//*[@resource-id='com.android.chrome:id/signin_fre_dismiss_button']`).click();
await driver.switchContext("WEBVIEW_chrome")
const username = driver.$(`//*[@name='acct']`)
await username.waitForDisplayed({timeout: 10 * 1000})
await username.click()
await username.setValue("myuser")
const password = driver.$(`//*[@name='pw']`)
await password.click()
await password.setValue("mypassword")
const loginButton = driver.$(`/html/body/form[1]/input`)
await loginButton.click()
const me = driver.$(`//*[@id='me']`)
await me.waitForDisplayed({timeout: 10 * 1000})
// so that we can see the UI
await driver.pause(5 * 1000)
// Open Chrome again and check if the session stays or not
const driver2 = await remote(
{
capabilities: {
'appium:waitForIdleTimeout': 100,
'appium:appPackage': 'com.android.chrome',
'appium:appActivity': 'com.google.android.apps.chrome.Main',
'appium:noReset': true,
'appium:fullReset': false,
'appium:allowTestPackages': true,
'appium:automationName': 'UiAutomator2',
'appium:deviceName': 'Android',
'appium:newCommandTimeout': 3600,
platformName: 'Android',
},
hostname: "localhost",
logLevel: "info",
port: 4723,
})
await driver2.url('');
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744694682a4588419.html
评论列表(0条)