HTMLUnit点击角度js锚点不打开模态窗口

时间:2017-06-02 21:04:59

标签: angularjs htmlunit

单击角度js锚点按钮应打开一种模态窗口(不是浏览器弹出窗口)。但是在点击后我没有得到新模态窗口的内容。

我检查了其他帖子,并确保javascript是可以删除的,我还添加了wait函数,但生成的网页与开头相同 - <input>元素与name="file"找不到。

我需要更改哪些内容才能使其正常工作?

这是相关按钮:

<a href="" ng-click="openUploadFileModal()" tooltip="Upload" tooltip-placement="bottom"><i class="fa fa-upload"></i></a>

我的java代码:

            WebClient webClient = new WebClient();
            webClient.getOptions().setThrowExceptionOnScriptError(false);
            webClient.setAjaxController(new NicelyResynchronizingAjaxController());

            HtmlPage p = webClient.getPage(activeProject);

            Optional<HtmlAnchor> anchor = p.getAnchors().stream()
                    .filter(a -> a.getAttribute("ng-click").equals("openUploadFileModal()")).findFirst();

            anchor.ifPresent(x -> {
                HtmlPage uploadPage;
                try {
                    uploadPage = x.click();
                    webClient.waitForBackgroundJavaScript(10000);
                    System.out.println(uploadPage.getWebResponse().getContentAsString());
                    System.out.println(uploadPage.getElementByName("file"));

                } catch (IOException e) {
                    e.printStackTrace();
                }

            });

在页面上,应显示以下div:

<div class="qq-uploader">
    <div class="qq-upload-drop-area" style="display: none;"><span>Drop files here to upload</span></div>
    <div class="qq-upload-button btn btn-primary btn-lg" style="position: relative; overflow: hidden; direction: ltr;">
        <div>Upload</div>
    <input multiple="multiple" name="file" type="file"></div>
    <span class="or btn-lg"> or </span>
    <span class="drag-here btn-lg">drag here</span>
    <span class="qq-drop-processing"><span>Processing dropped files...</span><span class="qq-drop-processing-spinner"></span></span>
    <div class="small"></div>
    <ul class="qq-upload-list"></ul>
</div>

在Firefox中它看起来像这样: Upload File modal dialog

0 个答案:

没有答案