Javascript 幻影可以';你不提交表格吗?

Javascript 幻影可以';你不提交表格吗?,javascript,java,html,forms,phantomjs,Javascript,Java,Html,Forms,Phantomjs,谁能看一下这张表格吗 使用chromedriver是可以的,但是PhantomJS不会点击submit按钮,也许它会点击它,但是表单不会被发送 JavaScript执行器-无 使用按钮id-无 使用按钮xpath-无 单击按钮前等待1分钟-无 单击按钮后等待1分钟-无 使用了5个不同版本的PhantomJS-nothing 设置不同的用户代理-无 设置不同的SSL容差-无 已使用。单击()-无 Used.submit()-无 在其他表单元素上使用了.submit()-无 设置不同的窗口大小-

谁能看一下这张表格吗

使用chromedriver是可以的,但是PhantomJS不会点击submit按钮,也许它会点击它,但是表单不会被发送

  • JavaScript执行器-无
  • 使用按钮id-无
  • 使用按钮xpath-无
  • 单击按钮前等待1分钟-无
  • 单击按钮后等待1分钟-无
  • 使用了5个不同版本的PhantomJS-nothing
  • 设置不同的用户代理-无
  • 设置不同的SSL容差-无
  • 已使用。单击()-无
  • Used.submit()-无
  • 在其他表单元素上使用了.submit()-无
  • 设置不同的窗口大小-无
  • 断言显示的元素返回true
  • 日志中没有错误
这些选项都不起作用。当我拍摄屏幕截图时,我可以看到字段中已经填充了数据,但是表单没有提交,我没有进入感谢页面

我可以转到页面,不输入任何数据并提交表单,我将看到客户端错误消息显示,告诉我该字段是必需的

这可能是什么原因造成的

更新添加一段代码,请注意,这在Chrome中确实有效,因此不会出现编码错误:

public void fillInForm(){
//Enters all the details
}


// Tried all three of these findBy, I do initalise the elements in the page construtor PageFactory.initElements(this.driver, this);
    //@FindBy(id="friend_submit")
    //@FindBy(xpath="//input[@type='submit']")
    @FindBy(xpath="//div//input[@type='submit']")
    private WebElement submitEmailButton;

    public void submitForm(){

        Assert.assertTrue(submitEmailButton.isDisplayed());

        webclientTestHelpers.scrollToElement(submitEmailButton, driver);

        // Trying to click using Java script
        JavascriptExecutor js = (JavascriptExecutor) driver;  
        js.executeScript("document.getElementById('friend_submit').click();");
        System.out.println("WE ARE ON::" + driver.getCurrentUrl()); // Page not moved

        System.out.println(submitEmailButton.isDisplayed() + "" + submitEmailButton.isEnabled()); // returns true ture so obviously the button click didn't work

        submitEmailButton.click();

        File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
        // Now you can do whatever you need to do with it, for example copy somewhere
        try {
            FileUtils.copyFile(scrFile, new File("C:\\screenshot\\TOOKASHOT.png")); // THis screenshot displays all the form details are correctly set so clicking the button should have sent the form
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

    }

请添加您尝试过的最小可复制代码示例。@Vaviloff我在上面添加了一些代码。PhantomJS binary是什么版本?下面是一个脚本,用于以原始PhantomJSese提交表单:。在phantomjsv2.5b上,只需要reCaptcha就可以真正发送。可能是Java驱动程序中特定于smth的。注意:本机
click()
在v2下不起作用。@瓦维洛夫感谢您的回复。奇怪的是,我没有看到reCaptcha,我已经在多个设备上尝试过,我愿意打赌,即使你可以点击验证码,它也不会通过,我可以填写表格,很好,我有截图来证明这一点,但点击按钮对字段中的数据没有任何作用。如果我点击没有数据的按钮,我会在电子邮件字段旁边出现“此字段是必需的”错误。奇怪的是,我可以按一下按钮,在预期的时候看到错误,但是有了有效的数据,我就被卡在页面上了。