简体   繁体   English

selenium ide导出到webdriver java

[英]selenium ide export to webdriver java

The "Java - WebDriverBackedSelenium" exporter I found generates code like this: selenium.open("/"); 我找到的“Java-WebDriverBackedSelenium”导出器生成如下代码:selenium.open(“/”); selenium.type("Password", "blah"); selenium.type(“密码”,“等等”); etc.. 等等..

But I need it to export like the classic WebDriver example below: 但我需要它像下面的经典WebDriver示例一样导出:

driver.get("http://www.google.com");
WebElement element = driver.findElement(By.name("q"));
element.sendKeys("Cheese!");

is there a way to export to the 2nd option? 有没有办法导出到第二个选项? I'm being asked to use this, and have used the ide to get the page id tags in the past, it would be nice to export to this format if possible. 我被要求使用它,并且过去使用了ide来获取页面id标签,如果可能的话,导出到这种格式会很好。 Does anyone know or have any opinions on this? 有没有人知道或对此有任何意见?

You can export the recorded Selenium tests as "JUnit 4 (WebDriver)" tests instead of "JUnit 4 (WebDriver Backed)" tests, if you need to use the WebDriver API class alone and not Selenium class in your tests. 如果您需要在测试中单独使用WebDriver API类而不是Selenium类,则可以将记录的Selenium测试导出为“JUnit 4(WebDriver)”测试,而不是“JUnit 4(WebDriver Backed)”测试。

PS: It would also help to use a more up to date version of the Selenium IDE; PS:使用更新版的Selenium IDE也会有所帮助; v.1.2.0 (which is the most recent version of the IDE as of now) definitely supports exporting tests cases to use the WebDriver API. v.1.2.0(截至目前为IDE的最新版本)肯定支持导出测试用例以使用WebDriver API。

Whilst on the IDE do the following... 在IDE上执行以下操作...

  • Click File 单击文件
  • Export Test Case As... 出口测试案例为......
  • Select Java / TestNG / WebDriver 选择Java / TestNG / WebDriver
  • Give the file a name, and ensure you put .java at the end of it eg test.java 给文件命名,并确保将.java放在它的末尾,例如test.java

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM