Switch to WebView Appium WebDriverIO

Profile picture for user devraj

Step 1: Wait Unit Context Length is More than 1

await driver.waitUntil(async ()=>{
    // Get All Context
    const contexts = await driver.getContexts();
    return contexts.length > 1;
}, 
// Timeout with message if context not found after 30 seconds
{timeout: 30000, timeoutMsg: 'Timeout waiting for context'});

Step 2: Switch to Web View with Index 1

await driver.switchContext(contexts[1])

Step 3: Switch to App with Index 0

await driver.switchContext(contexts[0])