简体   繁体   中英

Appium + saucelabs integration (JAVA) error

I have some troubles to connect with saucelabs. When I've tried to connect it, it shows me an error: Parameters were incorrect. We wanted {"required":["desiredCapabilities"],"optional":["requiredCapabilities","sessionId","id"]} and you sent ["requiredCapabilities","capabilities","desiredCapabilities"]

But I don't understand why happens that because I sent this capabilities:

    caps.setCapability("username", "myUser");
    caps.setCapability("accessKey", "myKey");
    caps.setCapability("appiumVersion", "1.5.3");
    caps.setCapability("deviceName","Samsung Galaxy Note Emulator");
    caps.setCapability("deviceOrientation", "portrait");
    caps.setCapability("browserName", "");
    caps.setCapability("platformVersion","4.1");
    caps.setCapability("platformName","Android");   
    caps.setCapability("app", "https://drive.google.com/uc?export=download&id=0B2etAlBEJtreUkJyaUxGMUh4NVE");
    caps.setCapability("appPackage", "io.appium.android.apis");
    caps.setCapability("appActivity", "io.appium.android.apis.graphics.FingerPaint");

And I've tried in different ways to sent it. For example:

//private final String USERNAME = "myUser";
//private final String ACCESS_KEY = "myKey";
//http://ondemand.saucelabs.com:80/wd/hub
//private final String URL = "https://" + USERNAME + ":" + ACCESS_KEY + "@ondemand.saucelabs.com:80/wd/hub";
driver = new AndroidDriver<WebElement>(new URL(URL,caps);

But this does not work.

And also, I don't get why it send twice my test to SauceLab When just I run once.

I'm using Selenium-webdriver 3.0.1, jdk8 u45 and appium java-client 4.1.2

I also was in testing Sauce Labs and it wasn't hard to setup, You have to follow their instructions.

Issue it might be in your URL, to be more exact in your port, shouldn't it be 443 instead of 80.

 String URL = "https://" + USERNAME + ":" + ACCESS_KEY + "@ondemand.saucelabs.com:443/wd/hub"

and not quite sure about app parameter.

Hope this should help.

This is a code sample from their page:

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;

import java.net.URL;

public class SampleSauceTest {

  public static final String USERNAME = "YOUR_USERNAME";
  public static final String ACCESS_KEY = "YOUR_ACCESS_KEY";
  public static final String URL = "https://" + USERNAME + ":" + ACCESS_KEY + "@ondemand.saucelabs.com:443/wd/hub";

  public static void main(String[] args) throws Exception {

    DesiredCapabilities caps = DesiredCapabilities.chrome();
    caps.setCapability("platform", "Windows 10");
    caps.setCapability("version", "latest");

    WebDriver driver = new RemoteWebDriver(new URL(URL), caps);

    /**
     * Goes to Sauce Lab's guinea-pig page and prints title
     */

    driver.get("https://saucelabs.com/test/guinea-pig");
    System.out.println("title of page is: " + driver.getTitle());

    driver.quit();
  }
}

https://wiki.saucelabs.com/display/DOCS/Java+Test+Setup+Example

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM