gpt4 book ai didi

java - Appium + Saucelabs 集成(JAVA)错误

转载 作者:太空宇宙 更新时间:2023-11-04 11:47:35 25 4
gpt4 key购买 nike

我在与 Saucelabs 连接时遇到一些问题。当我尝试连接它时,它显示一个错误:参数不正确。我们想要 {"required":["desiredCapabilities"],"optional":["requiredCapabilities","sessionId","id"]},而您发送了 ["requiredCapabilities","capability","desiredCapabilities"]

但我不明白为什么会发生这种情况,因为我发送了此功能:

    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");

我尝试过不同的方式来发送它。例如:

//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);

但这不起作用。

而且,我不明白为什么当我只运行一次时它会向 SauceLab 发送两次测试。

我正在使用 Selenium-webdriver 3.0.1、jdk8 u45 和 appium java-client 4.1.2

最佳答案

我也在测试 Sauce Labs,设置并不难,你必须遵循他们的说明。

问题可能出在您的 URL 中,更准确地说,出现在您的端口中,不应该是 443 而不是 80。

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

不太确定 app 参数。

希望这会有所帮助。

这是他们页面上的代码示例:

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

关于java - Appium + Saucelabs 集成(JAVA)错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42188789/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com