English 中文(简体)
HtmlUnit司机的网络司机和Popup
原标题:Webdriver and Popups in HtmlUnitDriver

I m目前试图使用网络用户HtmlUnithangr实施 Java本,并产生奇怪的结果。

同一条代码使用<代码>Firefox/63/7r/code>进行罚款。 然而,一旦被转往HtmlUnit的司机,便停止工作。 这里使用的简单代码Im是:

Alert alert = driver.switchTo().alert();
alert.accept();

是否HtmlUnit司机能够处理Java popups,或是HtmlUnit司机的这个限制点。

它是Javascript Confirm popup。 我们努力使用超额通用制导师的火ox特性:

driver = new HtmlUnitDriver(BrowserVersion.FIREFOX_3); 

这没有成功。

一个次要问题, Java是否需要使我们能与康肯普登箱互动的超文本自动制动因? 如果是YES,人们是否知道我们如何能够做到这一点?

driver = new HtmlUnitDriver(capabilities);

似乎没有工作,也没有得到承认。

Any help would be greatly appreciated. Cheers

问题回答

This appears to be a long running issue https://code.google.com/p/selenium/issues/detail?id=1105

I used a JavaScript workaround for the confirm popup. Here is an example in Python:

self.driver = WebDriver(
    command_executor= http://localhost:4444/wd/hub ,
    desired_capabilities=DesiredCapabilities.HTMLUNIT)

self.driver.execute_script("window.confirm = function(msg) {return true;};")
self.find_element_by_id( mybutton ).click()

在你使用之前,取消确认书的功能,使确认书成为接受书。 然后,你触发点击事件。 改用Cancel。

Pretty neat. I found this somewhere else on StackOverflow but can t remember where.





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签