Selenium webdriver 如何使用Robot Framework和Appium在Emulator上打开浏览器

Selenium webdriver 如何使用Robot Framework和Appium在Emulator上打开浏览器,selenium-webdriver,appium,robotframework,Selenium Webdriver,Appium,Robotframework,我正在尝试配置Robot框架,以便在android仿真器中打开Chrome浏览器。我有这样的代码: *** Settings *** Suite Setup Set Library Search Order SeleniumLibrary Test Setup Open page Test Teardown Close Page Library SeleniumLibrary Library Collections

我正在尝试配置Robot框架,以便在android仿真器中打开Chrome浏览器。我有这样的代码:

*** Settings ***
Suite Setup       Set Library Search Order    SeleniumLibrary
Test Setup        Open page
Test Teardown     Close Page
Library           SeleniumLibrary
Library           Collections
Library           requests
Library           AppiumLibrary

*** Test Cases ***
Test_case_sample
    Go To    https://www.google.com
    Sleep    10s

*** Keywords ***
Open Page
    ${desired_capabilities}=    Create Dictionary
    Set to Dictionary    ${desired_capabilities}    deviceName    Demo_6_Inch
    # Set to Dictionary    ${desired_capabilities}    build    test_run
    Set to Dictionary    ${desired_capabilities}    platformName    Android
    Set to Dictionary    ${desired_capabilities}    name    test_case_Sample
    Set to Dictionary    ${desired_capabilities}    platformVersion    8.0
    Set to Dictionary    ${desired_capabilities}    deviceOrientation    portrait
    Set to Dictionary    ${desired_capabilities}    browserName    Chrome
    Set to Dictionary    ${desired_capabilities}    appiumVersion    1.7.1
    Set to Dictionary    ${desired_capabilities}    deviceType    phone
    Create Webdriver    Remote    desired_capabilities=${desired_capabilities}

Close Page
    Close All Applications
运行脚本时,出现以下错误:

11:10:39.547创建远程WebDriver实例的信息。
11:10:40.548信息无法连接到主机127.0.0.1上的4444端口
11:10:40.548信息无法获取主机的IP地址:127.0.0.1
11:10:41.561失败URLError:urlopen错误[Errno 10061]无连接 由于目标计算机主动拒绝,因此无法生成

然后,我在localhost:4444上启动了一个SeleniumWebDriver实例。但这次我犯了一个错误:

WebDriverException:消息:转发新会话时出错 安装功能的VM池{appiumVersion:1.7.1,browserName: Chrome,deviceName:Demo_6_英寸,deviceOrientation:Picture, 设备类型:手机,名称:测试案例样本,平台名称:android, platformVersion:8.0}Stacktrace: 位于org.openqa.grid.web.servlet.handler.RequestHandler.process(RequestHandler.java:117) 位于org.openqa.grid.web.servlet.DriverServlet.process(DriverServlet.java:84) 位于org.openqa.grid.web.servlet.DriverServlet.doPost(DriverServlet.java:68) 位于javax.servlet.http.HttpServlet.service(HttpServlet.java:707) 位于javax.servlet.http.HttpServlet.service(HttpServlet.java:790) 位于org.seleniumhq.jetty9.servlet.ServletHolder.handle(ServletHolder.java:841) 位于org.seleniumhq.jetty9.servlet.ServletHandler.doHandle(ServletHandler.java:535) 位于org.seleniumhq.jetty9.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:188) 在org.seleniumhq.jetty9.server.session.SessionHandler.doHandle(session。。。 [超出限制的邮件内容已被删除。] 位于org.seleniumhq.jetty9.server.handler.ContextHandler.doScope(ContextHandler.java:1155) 位于org.seleniumhq.jetty9.server.handler.ScopedHandler.handle(ScopedHandler.java:141) 位于org.seleniumhq.jetty9.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132) 位于org.seleniumhq.jetty9.server.server.handle(server.java:561) 位于org.seleniumhq.jetty9.server.HttpChannel.handle(HttpChannel.java:334) 位于org.seleniumhq.jetty9.server.HttpConnection.onFillable(HttpConnection.java:251) 在org.seleniumhq.jetty9.io.AbstractConnection$ReadCallback.successed上 (AbstractConnection.java:279) 位于org.seleniumhq.jetty9.io.FillInterest.fillable(FillInterest.java:104) 位于org.seleniumhq.jetty9.io.ChannelEndPoint$2.run(ChannelEndPoint.java:124) 位于org.seleniumhq.jetty9.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:679) 位于org.seleniumhq.jetty9.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:597)

在java.lang.Thread.run(:-1) 如何克服这个问题并运行模拟器


感谢您提出解决此问题的建议

终于找到了简单的解决方案:

*** Settings ***
Library           SeleniumLibrary
Library           Collections

*** Variables ***

*** Test Cases ***
AndroidConnection
    ${Options}    Create Dictionary    androidPackage    com.android.chrome
    ${caps}    Create Dictionary    chromeOptions    ${Options}
    Set to Dictionary    ${caps}    platformName    Android
    Set to Dictionary    ${caps}    platformVersion    8.0
    Set To Dictionary    ${caps}    deviceName    emulator-5554
    Set To Dictionary    ${caps}    browserName    Chrome
    Create Webdriver    Remote    command_executor=http://localhost:4723/wd/hub    desired_capabilities=${caps}
    go to    http://www.google.com
    Close Browser

最终找到了简单的解决方案:

*** Settings ***
Library           SeleniumLibrary
Library           Collections

*** Variables ***

*** Test Cases ***
AndroidConnection
    ${Options}    Create Dictionary    androidPackage    com.android.chrome
    ${caps}    Create Dictionary    chromeOptions    ${Options}
    Set to Dictionary    ${caps}    platformName    Android
    Set to Dictionary    ${caps}    platformVersion    8.0
    Set To Dictionary    ${caps}    deviceName    emulator-5554
    Set To Dictionary    ${caps}    browserName    Chrome
    Create Webdriver    Remote    command_executor=http://localhost:4723/wd/hub    desired_capabilities=${caps}
    go to    http://www.google.com
    Close Browser