Search code examples
user-interfaceautomationappiumui-automation

Can you automate ui based web app with appium?


I have to automate an UI of web application. I also need to automate an UI in mobile. Does Appium supports both the platform ??? Anyone with knowledge of Appium can comment down below.


Solution

  • Yes, Appium works perfectly fine for hybrid (native + web) mobile apps:

    // assuming we have a set of capabilities
    driver = new AppiumDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
    
    Set<String> contextNames = driver.getContextHandles();
    for (String contextName : contextNames) {
        System.out.println(contextName); //prints out something like NATIVE_APP \n WEBVIEW_1
    }
    driver.context(contextNames.toArray()[1]); // set context to WEBVIEW_1
    
    //do some web testing
    String myText = driver.findElement(By.cssSelector(".green_button")).click();
    
    driver.context("NATIVE_APP");
    
    // do more native testing if we want
    
    driver.quit();
    

    More details are available in docs