应用问题,无法启动两个应用

时间:2019-02-25 10:52:16

标签: selenium appium

我无法使用APPIUM在单个脚本中启动两个应用,它显示错误为

  

在处理命令时发生未知的服务器端错误。   所需的内容不应同时包含“ appPackage”和   'browserName'

public class SalesLeadProg { 
  public AndroidDriver<MobileElement> driver;
  private WebElement element; public WebDriverWait wait;

  @BeforeMethod 
  public void setup() throws MalformedURLException, InterruptedException { 
    DOMConfigurator.configure("log4j.xml");
    DesiredCapabilities caps = new DesiredCapabilities(); 
    caps.setCapability("automationName", "UiAutomator2"); 
    caps.setCapability("deviceName", "sunil");
    caps.setCapability("udid", "422b21e7");
    caps.setCapability("platformName", "Android"); 
    caps.setCapability("platformVersion", "8.1.0"); 
    caps.setCapability("appPackage", "com.mfcwl.mfc_dealer"); 
    caps.setCapability("appActivity", "com.mfcwl.mfc_dealer.Activity.SplashActivity"); 
    caps.setCapability("autoAcceptAlerts", true); 
    caps.setCapability("noReset", true); 
    caps.setCapability("browserName", "Chrome"); 
    //it will launch the chrome browser in mobile 
    caps.setCapability(ChromeOptions.CAPABILITY, true); 
    ChromeOptions options=new ChromeOptions(); 
    options.setExperimentalOption("androidPackage", "com.android.chrome");
     caps.setCapability("autoGrantPermissions", true);
    // to allow the permission of contacts camara, which comes in the begining when we install the app*/ 
     caps.setCapability("unicodeKeyboard", true);
   // to make the keyboard working 
   caps.setCapability("resetKeyboard", false); 
   // it 
   try { 
       driver = new AndroidDriver<MobileElement> (new URL("0.0.0.0:4723/wd/hub"),caps); 
  }
  catch(MalformedURLException e) { 
    System.out.println(e); 
  } 
  driver.manage().timeouts().implicitlyWait(16, TimeUnit.SECONDS); 
} 

@Test 
public void Dashboard() throws MalformedURLException, InterruptedException { 
 MobileElement email = driver.findElement(By.id("com.mfcwl.mfc_dealer:id/email")); 
 Thread.sleep(4000); 
 WebDriverWait wait = new WebDriverWait(driver, 10); 
 wait.until(ExpectedConditions.visibilityOf(email)); 
 boolean isElementPresent = email.isDisplayed(); 
 System.out.println(isElementPresent); 
 Thread.sleep(4000); 
 driver.findElementById("com.mfcwl.mfc_dealer:id/email").clear();
 driver.findElementById("com.mfcwl.mfc_dealer:id/email").sendKeys("prestige");
 System.out.println("Entered ID");

driver.findElement(By.id("com.mfcwl.mfc_dealer:id/password")).clear(); 
driver.findElement(By.id("com.mfcwl.mfc_dealer:id/password")).sendKeys("Mahindra"); 
System.out.println("Entered Password"); 
driver.findElement(By.id("com.mfcwl.mfc_dealer:id/email_sign_in_button")).click(); 
//to login 
System.out.println("Signed IN");
Thread.sleep(4000); 
 driver.findElement(By.id("com.mfcwl.mfc_dealer:id/homeTab")).click();
//to click on home button 
 System.out.println("Clicked on Home button"); 
 Thread.sleep(3000); //Set ChromeDriver location 
 System.setProperty("webdriver.chrome.driver", "./ChromeDriver/chromedriver.exe");
 driver.get("google.com/");   driver.findElement(By.id("com.mfcwl.mfc_dealer:id/click_lead")).click(); 

 System.out.println("Clicked on Today's follow up leads section");     
driver.findElement(By.id("com.mfcwl.mfc_dealer:id/lead_filter")).click();

请提供有关如何通过单个脚本在APPIUM中使用两个应用程序的解决方案。

0 个答案:

没有答案