且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

WebDriver:更改事件未触发

更新时间:2023-02-13 14:30:52

所以我相信我已经发现了我的问题。我会完全承认这是PEBKAC。如果浏览器窗口没有主动关注,我忘记了WebDriver有问题机器(这对我来说仍然很奇怪)。当我调试问题时,我正在使用我的编辑器逐步完成代码。通过正常运行代码而不从浏览器中移除焦点,事件按照预期使用所有三个解决方案激活(标签,点击,和javascript)。

So I believe I have found out my problem. I will fully admit this was PEBKAC. I had forgotten that WebDriver has issues if the browser window is not in active focus on the machine (which is still weird to me). When I was debugging the problem, I was using my editor to step through the code. By running the code normally and without removing focus from the browser, the events fire as expected using all three solutions (tab, click-away, and javascript).

我有一个显示所有三种方法的示例项目,但是我是git和github的主要菜鸟,并且在交付项目时遇到了问题。一旦我明白了,我将与大家分享这个项目。

I have an example project showing all three methods, however I am a major noob with git and github and am having problems delivering the project. Once i figure that out, I will share the project with you all.

编辑:在GitHub上获取示例代码( https://github.com/loesak/knockout.webdriver.change.event.test )。您可以将项目作为服务器中的webapp启动并手动运行测试,也可以通过maven运行测试( mvn clean install )。我并没有付出太多努力让这个工作变得健壮,所以假设你安装了Firefox并且端口 0808 8080已经打开。

EDIT: Got the example code up on GitHub (https://github.com/loesak/knockout.webdriver.change.event.test). You can either start the project as a webapp in a server and run the test manually or you can run the tests via maven (mvn clean install). I didn't put a whole lot of effort into getting this to work robustly so it is assuming you have Firefox installed and port 0808 8080 is open.

编辑:修正了已声明的端口号

EDIT: Fixed stated port number