Java Fitnesse中click()不在HtmlUnitDriver中工作的解决方法?
我有一个jUnit测试,运行一个Fitnesse测试,测试一些网页。在开发模式下,我使用FirefoxDriver,所有测试运行良好,网页如预期般弹出 当我尝试以自动化模式运行测试时,即使用Maven,测试失败得很惨。你们中有人对可能出现的问题或解决方法有什么建议吗 相关代码:Java Fitnesse中click()不在HtmlUnitDriver中工作的解决方法?,java,firefox,click,htmlunit,fitnesse,Java,Firefox,Click,Htmlunit,Fitnesse,我有一个jUnit测试,运行一个Fitnesse测试,测试一些网页。在开发模式下,我使用FirefoxDriver,所有测试运行良好,网页如预期般弹出 当我尝试以自动化模式运行测试时,即使用Maven,测试失败得很惨。你们中有人对可能出现的问题或解决方法有什么建议吗 相关代码: -网页: <form method="get" action="/someAction.do" name="my_form"> <input id="fetch_new_su
-网页:
<form method="get" action="/someAction.do" name="my_form">
<input id="fetch_new_submit" class="ui-button ui-widget ui-state-default ui-corner-all" type="submit" onclick="showWaitMsg()" value="Fetch new orders" role="button">
</form>
- 固件代码:
类固定装置public boolean pressSubmitButton(String buttonText) { try { List<WebElement> buttons = getWebDriver().findElements(By.tagName("input")); for (WebElement button : buttons) { if (button.getAttribute("value").equals(buttonText)) { System.out.println("found button '" + button.getAttribute("value") + "'."); button.click(); //HERE return true; } } } catch (Exception e) { LOG.debug("Some error occured, e); return false; } LOG.debug("Did not find the button"); return false; }
public boolean按SubmitButton(字符串按钮文本){ 试一试{ 列表按钮=getWebDriver().findElements(按.tagName(“输入”)); 用于(WebElement按钮:按钮){ 如果(button.getAttribute(“value”).equals(buttonText)){ System.out.println(“找到的按钮“+”按钮.getAttribute(“值”)+“.”); 按钮。单击();//此处 返回true; } } }捕获(例外e){ LOG.debug(“发生了一些错误,e”); 返回false; } 调试(“没有找到按钮”); 返回false; }
-getWebDriver()返回FirefoxDriver工作正常。
-getWebDriver返回新的HtmlUnitDriver(true),即启用javascript时,忽略按钮。此处的click()。此处的button.submit()也被忽略,button.sendKeys(“\n”)抛出一个“未启用”元素错误。
-我们使用版本2.0rc2
我们的自动测试无法使用FirefoxDriver。对于这个问题,是否有任何已知的解决方法?进一步的测试和使用最新技术,即快照给了我一些暂时有效的方法 即:
-将硒升级至2.0rc3
-将htmlunit升级到2.9快照 还有更多的实验:
final HtmlUnitDriver driver = new HtmlUnitDriver(BrowserVersion.FIREFOX_3_6);
Firefox版本现在适用于提交类型按钮,但javascript操作失败。这也可能是因为我在使用Firefox 4.0.1.browser时使用了Firefox_3_6版本驱动程序
IE版本_8在单击()时挂起
但是,普通的HtmlUnitDriver()可以工作