我已经使用Selenium ide记录测试用例,将它们导出到Groovy源代码,根据需要进行修改并运行它们。默认代码需要localhost上的服务器,我想在远程机器上使用服务器。我怎样才能做到这一点?在查看GroovySeleneseTestCase的文档时,不会出现允许您使用远程服务器的setUp()方法。我能想到的唯一选择是通过setUp()方法中的默认硒对象设置服务器主机和端口,但不知道如何执行此操作。使用来自Selenium的远程Selenium服务器编写的Groovy测试用例
1
A
回答
0
在Java:
HttpCommandProcessor processor = new HttpCommandProcessor("localhost", 3300, browserName, appBaseURL);
selenium = new CustomSelenium(processor, browserName, waitToLoadTimeout, waitForConditionTimeout);
selenium.start();
只是通过服务器的地址和正确的端口替换本地主机和3300。我不知道Groovy,但它应该没有太大的不同。当然,服务器必须先启动并配置防火墙。
0
为了得到这个工作,我不得不创建一个GroovySelenium的自定义实例,将其分配给测试类,而不是调用super.setUp方法。代码示例如下。
void setUp(String selServer, int selPort, String browser, String basePath) throws Exception {
def tempSel=new DefaultSelenium(selServer, selPort, browser, basePath)
selenium= new GroovySelenium(tempSel)
selenium.start()
setDefaultTimeout(30000)
setCaptureScreenshotOnFailure(false)
}
假设你有一个名为MyTest的类此设置方法,要测试google.com使用硒服务器的主机名MYSERVER,端口5555,并使用Internet Explorer作为浏览器下面的代码会工作。
test=New MyTest()
test.setUp("myserver",5555,"*iexplore","http://www.google.com")
test.testMyTest()
相关问题
- 1. 水豚现有的测试+使用Selenium对远程服务器运行测试
- 2. 使用PageFactory(Selenium-WebDriver)编写测试用例。优点?
- 3. Junit/selenium测试用例
- 4. selenium - node.js - wd测试用例
- 5. 使用Selenium的Web服务自动化测试
- 6. 使用Selenium进行微服务架构的测试自动化
- 7. 如何为特定的GWT Widget编写Selenium测试用例?
- 8. 使用Selenium测试用例映射手动测试用例
- 9. Javascript + selenium,编写可读的测试
- 10. 如何编写包含多个测试用例的Python Selenium测试脚本?
- 11. 使用Selenium和Cucumber进行Web服务测试自动化
- 12. 使测试取决于其他测试Selenium服务器
- 13. 用于Javascript测试的Selenium vs Selenium
- 14. Selenium WebDriver和Selenium服务器
- 15. Selenium测试用例中的循环 - java
- 16. 对Kubernetes环境中的远程Selenium服务器运行Nightwatch.js测试
- 17. 测试使用Messenger的远程服务
- 18. Selenium-Server和Selenium测试不支持Web的服务
- 19. 使用Selenium自动测试UIWebView内容
- 20. 使用Selenium webdriver测试自动填充
- 21. 使用以Java编写的现有Selenium测试的AngularJs端对端测试
- 22. 写Selenium Test来测试文字换行?
- 23. 如何使用Selenium服务器独立测试https web应用程序?
- 24. 使用selenium webdriver测试Highcharts
- 25. 使用Selenium测试Highcharts
- 26. 使用Selenium Webdriver测试sessionStorage
- 27. Selenium使用硒测试
- 28. 这个测试用例(使用Selenium WebDriver编写的Java)如何看起来像是使用了Conductor框架?
- 29. 如何在用C#编写的Selenium WebDriver(Nunit测试用例)中按“Enter”?
- 30. Selenium测试用的Xvfb