在Android移动模拟器上运行Selenium Webdriver测试

时间:2014-12-12 12:36:07

标签: java android selenium android-emulator appium

我正在尝试在移动模拟器上运行WebDriver测试,但它似乎无法正常工作 所以这是我的设置快速运行:

  1. 我使用Eclipse
  2. 在Java中编写测试
  3. 我正在使用带有TestNG框架的WebDriver
  4. 我正在使用Appium,我已经下载了Android SDK
  5. 我在我的模拟器上安装了android服务器和android WebDriver
  6. 我正在设置像这样的Appium

       File appDir = new File("C:/Appium");
       File app = new File(appDir, "android-server-2.38.0.apk");
       DesiredCapabilities capabilities = new DesiredCapabilities();
       capabilities.setCapability("deviceName","Android Emulator");
       capabilities.setCapability("browsername",  "safari");
       capabilities.setCapability("platformVersion", "4.4");
       capabilities.setCapability("platformName", "Android");
       capabilities.setCapability("app", app.getAbsolutePath());
    

    每次运行测试时,我都会在模拟器上看到一个黑屏,所有内容都显示为“WebDriver Ready”,然后黑屏关闭并在我的控制台上显示“尚未实现”

    FAILED CONFIGURATION: @BeforeMethod setUp
    org.openqa.selenium.WebDriverException: Not yet implemented. Please help us: http://appium.io/get-involved.html (WARNING: The server did not provide any stacktrace information)
    Command duration or timeout: 9 milliseconds
    Build info: version: '2.44.0', revision: '76d78cf', time: '2014-10-23 20:02:37'
    System info: host: 'C025', ip: '169.254.167.218', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.7.0_51'
    Session ID: d72cf56d-8364-4353-92a4-817c377a60b2
    Driver info: org.openqa.selenium.remote.RemoteWebDriver
    Capabilities [{platformVersion=4.4, app=C:\Appium\android-server-2.38.0.apk, platform=LINUX, databaseEnabled=false, javascriptEnabled=true, browsername=safari, platformName=Android, deviceName=Android Emulator, browserName=Android, webStorageEnabled=false, networkConnectionEnabled=true, desired={platformVersion=4.4, app=C:\Appium\android-server-2.38.0.apk, browsername=safari, deviceName=Android Emulator, platformName=Android}, locationContextEnabled=false, warnings={}, takesScreenshot=true}]
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
        at java.lang.reflect.Constructor.newInstance(Unknown Source)
        at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:204)
        at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:156)
        at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:599)
        at org.openqa.selenium.remote.RemoteWebDriver.get(RemoteWebDriver.java:304)
        at RegisterUser.setUp(RegisterUser.java:51)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84)
        at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:564)
        at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:213)
        at org.testng.internal.Invoker.invokeMethod(Invoker.java:653)
        at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901)
        at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231)
        at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)
        at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
        at org.testng.TestRunner.privateRun(TestRunner.java:767)
        at org.testng.TestRunner.run(TestRunner.java:617)
        at org.testng.SuiteRunner.runTest(SuiteRunner.java:334)
        at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329)
        at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)
        at org.testng.SuiteRunner.run(SuiteRunner.java:240)
        at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
        at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
        at org.testng.TestNG.runSuitesSequentially(TestNG.java:1224)
        at org.testng.TestNG.runSuitesLocally(TestNG.java:1149)
        at org.testng.TestNG.run(TestNG.java:1057)
        at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:111)
        at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:204)
        at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:175)
    

    如果有人能帮我解决这个问题,我将不胜感激。我不是WebDriver的新手,但我是移动测试的新手。

    班级的完整结构......

    import java.io.File;
    import java.net.MalformedURLException;
    import java.net.URL;
    
    import org.openqa.selenium.By;
    import org.openqa.selenium.Platform;
    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.remote.CapabilityType;
    import org.openqa.selenium.remote.DesiredCapabilities;
    import org.openqa.selenium.remote.RemoteWebDriver;
    import org.openqa.selenium.safari.SafariDriver;
    import org.testng.annotations.AfterMethod;
    import org.testng.annotations.BeforeMethod;
    import org.testng.annotations.Test;
    
    
    public class RegisterUser {
    
        private WebDriver driver;
    
        @BeforeMethod()
        public void setUp() throws MalformedURLException {
    
        }
    
        @Test()
        public void registerNewUser() throws Exception {        
    
        }
    
    
        @AfterMethod
        public void tearDown() throws Exception {       
    
        }
    }
    

0 个答案:

没有答案