无法针对我的硒自动化移动脚本在ucelabs上启动新会话

时间:2018-11-12 06:38:37

标签: java android selenium-webdriver saucelabs

在ucelabs上运行硒自动化脚本,但低于错误。找不到失败原因。:- 注意:-还提到了以前在stackoverflow上问过的类似问题,但并没有帮助我。

  

失败的配置:@BeforeClass设置       org.openqa.selenium.remote.UnreachableBrowserException:无法启动新的会话。可能的原因是遥控器的地址无效   服务器或浏览器启动失败。       内部版本信息:版本:“ 2.48.2”,修订版:“ 41bccdd”,时间:“ 2015-10-09 19:59:12”       系统信息:主机:'ULTP_444',ip:'172.24.7.181',操作系统名称:'Windows 10',os.arch:'amd64',os.version:'10 .0',java.version:   '1.8.0_181'       驱动程序信息:driver.version:AndroidDriver         在org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:641)         在io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:40)         在io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:1)         在io.appium.java_client.android.AndroidDriver.execute(AndroidDriver.java:1)         在org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:247)         在org.openqa.selenium.remote.RemoteWebDriver。(RemoteWebDriver.java:129)         在org.openqa.selenium.remote.RemoteWebDriver。(RemoteWebDriver.java:142)         在io.appium.java_client.DefaultGenericMobileDriver。(DefaultGenericMobileDriver.java:36)         在io.appium.java_client.AppiumDriver。(AppiumDriver.java:114)         在io.appium.java_client.AppiumDriver。(AppiumDriver.java:132)         在io.appium.java_client.android.AndroidDriver。(AndroidDriver.java:92)         在com.automation.mobile.Tests.TestBase.setup(TestBase.java:43)         在sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法)处         在sun.reflect.NativeMethodAccessorImpl.invoke(未知来源)         在sun.reflect.DelegatingMethodAccessorImpl.invoke(未知来源)         在java.lang.reflect.Method.invoke(未知来源)         在org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:85)         在org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:510)         在org.testng.internal.Invoker.invokeConfigurations(Invoker.java:211)         在org.testng.internal.Invoker.invokeConfigurations(Invoker.java:138)         在org.testng.internal.TestMethodWorker.invokeBeforeClassMethods(TestMethodWorker.java:170)         在org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:104)         在org.testng.TestRunner.privateRun(TestRunner.java:773)         在org.testng.TestRunner.run(TestRunner.java:623)         在org.testng.SuiteRunner.runTest(SuiteRunner.java:357)         在org.testng.SuiteRunner.runSequentially(SuiteRunner.java:352)         在org.testng.SuiteRunner.privateRun(SuiteRunner.java:310)         在org.testng.SuiteRunner.run(SuiteRunner.java:259)         在org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)         在org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)         在org.testng.TestNG.runSuitesSequentially(TestNG.java:1185)         在org.testng.TestNG.runSuitesLocally(TestNG.java:1110)         在org.testng.TestNG.run(TestNG.java:1018)         在org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:114)         在org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)         在org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)       引起原因:org.openqa.selenium.WebDriverException:javax.net.ssl.SSLException:无法识别的SSL消息,纯文本   连接?       内部版本信息:版本:“ 2.48.2”,修订版:“ 41bccdd”,时间:“ 2015-10-09 19:59:12”       系统信息:主机:'ULTP_444',ip:'172.24.7.181',操作系统名称:'Windows 10',os.arch:'amd64',os.version:'10 .0',java.version:   '1.8.0_181'       驱动程序信息:driver.version:AndroidDriver         在io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:84)         在org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:620)         ...另外35个       由以下原因引起:javax.net.ssl.SSLException:无法识别的SSL消息,纯文本连接?         在sun.security.ssl.InputRecord.handleUnknownRecord(未知来源)         在sun.security.ssl.InputRecord.read(未知来源)         在sun.security.ssl.SSLSocketImpl.readRecord(未知来源)         在sun.security.ssl.SSLSocketImpl.performInitialHandshake(未知来源)         在sun.security.ssl.SSLSocketImpl.startHandshake(未知来源)         在sun.security.ssl.SSLSocketImpl.startHandshake(未知来源)         在org.apache.http.conn.ssl.SSLConnectionSocketFactory.createLayeredSocket(SSLConnectionSocketFactory.java:394)         在org.apache.http.conn.ssl.SSLConnectionSocketFactory.connectSocket(SSLConnectionSocketFactory.java:353)         在org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:134)         在org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:353)         在org.apache.http.impl.execchain.MainClientExec。建立路由(MainClientExec.java:380)         在org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:236)         在org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:184)         在org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:88)         在org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)         在org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:184)         在org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:71)         在org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:55)         在org.openqa.selenium.remote.internal.ApacheHttpClient.fallBackExecute(ApacheHttpClient.java:143)         在org.openqa.selenium.remote.internal.ApacheHttpClient.execute(ApacheHttpClient.java:89)         在org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:142)         在io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:69)

下面是我的硒脚本:-

import java.net.MalformedURLException;
import java.net.URL;
import java.util.concurrent.TimeUnit;

import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.testng.Assert;
import org.testng.ITestResult;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

import io.appium.java_client.AppiumDriver;
import io.appium.java_client.MobileElement;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.remote.AndroidMobileCapabilityType;


public class TestBase {
    AppiumDriver<MobileElement> driver;
    public static final String USERNAME = "xxx";
    public static final String ACCESS_KEY = "yyy";
    public static final String URL = "https://" + USERNAME + ":" + ACCESS_KEY + "@ondemand.saucelabs.com:80/wd/hub";

    @BeforeClass
    public void setup() throws MalformedURLException {
        DesiredCapabilities capabilities = new DesiredCapabilities();
        capabilities.setCapability("name", "Calculator_test");
        capabilities.setCapability("deviceName", "Samsung Galaxy S4 Emulator");
        capabilities.setCapability("platformVersion", "4.4");
        capabilities.setCapability("platformName", "Android");
        capabilities.setCapability("noReset", "true");
        capabilities.setCapability("fullReset", "false");
        capabilities.setCapability("browserName", "");
        capabilities.setCapability("appiumVersion", "1.5.3");
        capabilities.setCapability(AndroidMobileCapabilityType.APP_PACKAGE, "com.android.calculator2");
        capabilities.setCapability(AndroidMobileCapabilityType.APP_ACTIVITY, "com.android.calculator2.Calculator");

        driver=new AndroidDriver<MobileElement>(new URL(URL),capabilities);

        driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);

    }

    @Test
    public void run() {
        driver.findElementById("com.android.calculator2:id/digit_7").click();
        driver.findElementByAccessibilityId("plus").click();
        driver.findElementByXPath("//*[@text='2']").click();
        driver.findElementByAccessibilityId("equals").click();
        String result=driver.findElementById("com.android.calculator2:id/result").getText();
        if(result.equals("9"))
            Assert.assertTrue(true);
        else
            Assert.assertTrue(false);
    }

    @AfterClass
    public void tearDown(ITestResult result) {
        ((JavascriptExecutor) driver).executeScript("sauce:job-result=" + (result.isSuccess() ? "passed" : "failed"));
        driver.quit();
    }
}

0 个答案:

没有答案