Chromedriver点击按钮并提交表单但phantomjs没有

时间:2017-01-29 12:24:14

标签: java selenium webdriver phantomjs selenium-chromedriver

有人可以帮助我,因为它让我发疯了!

我正在尝试自动化此页面:http://www.zoopla.co.uk/friend/42816744?section=for-sale&search_identifier=6323219902a84fc51cd97861178ef6ce

对于提交按钮,我尝试过使用这两个findBy:

  

@FindBy(ID =" friend_submit&#34)

     

@FindBy(的xpath =" //输入[@type ='提交']&#34)

使用ChromeDriver工作正常,我可以填写表格然后提交,然后看看"谢谢你"下一页上的消息。

问题在于phantomJS(我使用webdriverManager,因此它总是下载当前正在使用的最新版本" .m2 \ repository \ webdriver \ phantomjs \ windows \ 2.5.0 \ phantomjs.exe&# 34;)它填写表单,但然后点击按钮什么都不做。

下一步而不是期待我进入/ success /页面我还在表单页面上。

我已经尝试了所有东西,从点击到waitng添加超长等待,调用button.submit();我甚至尝试多次点击按钮,但仍然在页面上(愚蠢的我知道,但我一直试图让这个工作几个小时!)

使用ChromeDriver我没有设置任何DesiredCapabilities,但是使用PhantomJS我已经看到很多人设置这些,所以我目前正在使用:

    DesiredCapabilities desiredCapabilities = DesiredCapabilities.phantomjs();
    desiredCapabilities.setJavascriptEnabled(true);
    desiredCapabilities.setCapability(PhantomJSDriverService.PHANTOMJS_CLI_ARGS, new String[] {"--web-security=false", "--ignore-ssl-errors=true", "--ssl-protocol=any"});
    driver = new PhantomJSDriver(desiredCapabilities);

有人可以建议为什么它在chromeDriver中提交表单而不是phantomJS?

这可能与phantomjs如何呈现页面有关吗?我将窗口大小设置为全屏,我尝试滚动到元素,如果我断言元素显示我得到了真,所以按钮就在那里它只是点击它(通过点击或JS)isn& #39; t提交表格。

更新: 好吧,我可能会到某个地方,我已经编写了一个测试来提交没有数据的表单并断言你在页面上看到了错误消息,这个测试通过了。它调用相同的代码来单击提交按钮。

我还在测试中截取了屏幕截图,失败的是填写表单,所以点击应该带我到下一页。有没有数据点击的任何想法都会显示错误信息,但点击有效数据什么都不做?

0 个答案:

没有答案
相关问题