如何使用Robot Framework和Appium在Emulator上打开浏览器 [英] How Do I Open a browser on Emulator using Robot Framework and Appium
问题描述
我正在尝试配置机器人框架以在Android模拟器中打开Chrome浏览器.我有以下代码可以做到这一点:
I am trying to configure Robot Framework to open Chrome Browser in an android emulator. I have this code to do that:
*** 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
运行脚本时,出现以下错误:
When running the script, I get the following error :
11:10:39.547信息创建远程WebDriver的实例.
11:10:40.548 INFO无法连接到主机127.0.0.1上的端口4444
11:10:40.548 INFO无法获取主机的IP地址:127.0.0.1
11:10:41.561 FAIL URLError:urlopen错误[Errno 10061]无连接 可能是因为目标计算机主动拒绝了它
11:10:39.547 INFO Creating an instance of the Remote WebDriver.
11:10:40.548 INFO Could not connect to port 4444 on host 127.0.0.1
11:10:40.548 INFO Could not get IP address for host: 127.0.0.1
11:10:41.561 FAIL URLError: urlopen error [Errno 10061] No connection could be made because the target machine actively refused it
然后我在localhost:4444启动了一个硒Webdriver实例.但是这次我得到了这个错误:
I than started an instance of selenium webdriver at localhost:4444 . But this time I got this error:
WebDriverException:消息:转发新会话时出错空 用于设置功能的虚拟机池{appiumVersion:1.7.1,browserName: Chrome,deviceName:Demo_6_Inch,deviceOrientation:纵向, deviceType:电话,名称:test_case_Sample,platformName: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(Sessio ... [超出限制的邮件内容已被删除. ] 在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.succeeded (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)
WebDriverException: Message: Error forwarding the new session Empty pool of VM for setup Capabilities {appiumVersion: 1.7.1, browserName: Chrome, deviceName: Demo_6_Inch, deviceOrientation: portrait, deviceType: phone, name: test_case_Sample, platformName: android, platformVersion: 8.0} Stacktrace: at org.openqa.grid.web.servlet.handler.RequestHandler.process (RequestHandler.java:117) at org.openqa.grid.web.servlet.DriverServlet.process (DriverServlet.java:84) at org.openqa.grid.web.servlet.DriverServlet.doPost (DriverServlet.java:68) at javax.servlet.http.HttpServlet.service (HttpServlet.java:707) at javax.servlet.http.HttpServlet.service (HttpServlet.java:790) at org.seleniumhq.jetty9.servlet.ServletHolder.handle (ServletHolder.java:841) at org.seleniumhq.jetty9.servlet.ServletHandler.doHandle (ServletHandler.java:535) at org.seleniumhq.jetty9.server.handler.ScopedHandler.nextHandle (ScopedHandler.java:188) at org.seleniumhq.jetty9.server.session.SessionHandler.doHandle (Sessio... [ Message content over the limit has been removed. ] at org.seleniumhq.jetty9.server.handler.ContextHandler.doScope (ContextHandler.java:1155) at org.seleniumhq.jetty9.server.handler.ScopedHandler.handle (ScopedHandler.java:141) at org.seleniumhq.jetty9.server.handler.HandlerWrapper.handle (HandlerWrapper.java:132) at org.seleniumhq.jetty9.server.Server.handle (Server.java:561) at org.seleniumhq.jetty9.server.HttpChannel.handle (HttpChannel.java:334) at org.seleniumhq.jetty9.server.HttpConnection.onFillable (HttpConnection.java:251) at org.seleniumhq.jetty9.io.AbstractConnection$ReadCallback.succeeded (AbstractConnection.java:279) at org.seleniumhq.jetty9.io.FillInterest.fillable (FillInterest.java:104) at org.seleniumhq.jetty9.io.ChannelEndPoint$2.run (ChannelEndPoint.java:124) at org.seleniumhq.jetty9.util.thread.QueuedThreadPool.runJob (QueuedThreadPool.java:679) at org.seleniumhq.jetty9.util.thread.QueuedThreadPool$2.run (QueuedThreadPool.java:597)
如何克服这个问题并运行模拟器?
How can I overcome this and run the emulator?
感谢您提出的解决此问题的建议
Thanks for your suggestion to solve this
推荐答案
最后找到了简单的解决方案:
Finally found the simple solution :
*** 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
这篇关于如何使用Robot Framework和Appium在Emulator上打开浏览器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!