mercredi 30 mai 2018

appium webdriver remoteserver UnreachableBrowserException

package basic_scenario;

import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.openqa.selenium.remote.UnreachableBrowserException;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;



public class Login_TG {


    WebDriver driver;
    @BeforeTest
    public void setup() throws MalformedURLException
    {
        String apkpath="C:\\Users\\rgi-40\\android-sdks\\platform-tools\\GG.apk";
        File app=new File(apkpath);

        DesiredCapabilities capabilities = new DesiredCapabilities();

        capabilities.setCapability("browserName", "");
        capabilities.setCapability("deviceName", "emulator-5554");
        capabilities.setCapability("PlatformVersion", "6.0");
        capabilities.setCapability("app", app.getAbsolutePath());
        capabilities.setCapability("platformName", "Android");  
        capabilities.setCapability("noReset", true);
        capabilities.setCapability("appActivity", "com.globalgarner.BaseClasses.Navigation.Activity.SplashScreenActivity");
        capabilities.setCapability("appPackage", "com.globalgarner");
        capabilities.setCapability("autoGrantPermissions",true);
        capabilities.setCapability("newCommandTimeout", "60");
        capabilities.setCapability("automationName", "Appium");
        //capabilities.setCapability("--session-override",true);



        try{
        driver = new RemoteWebDriver(new URL("http://127.0.0.1:5038/wd/hub"), capabilities);

        }catch(UnreachableBrowserException e){

                System.out.println("cant find driver");

        }


    }
@Test
  public void testLogin() throws Exception {


            WebElement login_element = driver.findElement(By.id("com.globalgarner:id/act_tutorial_btn_login"));
            login_element.click();

            WebElement uname_element = driver.findElement(By.className("android.widget.EditText"));
            uname_element.sendKeys("test");

            WebElement pwd_element = driver.findElement(By.id("com.globalgarner:id/fragment_login_edt_password"));
            pwd_element.sendKeys("test");

            WebElement submit_element = driver.findElement(By.id("com.globalgarner:id/fragment_login_btn_login"));
            submit_element.click();
        }

@AfterTest
  public void teardown() {

        driver.quit();
    }

}

windows 10 osenter image description here Appium version = 1.6.1 Eclipse : neon 3.

First whole code is run perfect but after running multiple time test it shows "unreachablebrowserexception"

i am not able to handle unreachable browser exception, if i am using androiddriver and appiumdriver , i am not able to getting the element inside testLogin() method.

Aucun commentaire:

Enregistrer un commentaire