Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/407.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在webdriver java中使用jscroll窗格滚动_Java_Javascript_Selenium Webdriver - Fatal编程技术网

如何在webdriver java中使用jscroll窗格滚动

如何在webdriver java中使用jscroll窗格滚动,java,javascript,selenium-webdriver,Java,Javascript,Selenium Webdriver,窗格保持不变时未进入视图的元素。我相信如果我向下滚动窗格,可能会解决这个问题 所以基本上我想向下滚动一个div到一个元素,以便进入可见性 我需要将哪段代码添加到我的webdriver java中 我尝试了以下方法,但没有成功: WebDriver driver = null; JavascriptExecutor js = (JavascriptExecutor) driver; js.executeScript("$('#fed-panel').data('jsp').scrollTo

窗格保持不变时未进入视图的元素。我相信如果我向下滚动窗格,可能会解决这个问题

所以基本上我想向下滚动一个div到一个元素,以便进入可见性

我需要将哪段代码添加到我的webdriver java中

我尝试了以下方法,但没有成功:

WebDriver driver = null;
JavascriptExecutor js = (JavascriptExecutor) driver;    
js.executeScript("$('#fed-panel').data('jsp').scrollToBottom()");

我在代码中使用以下内容来处理一些仅在向下滚动时出现的Ajax对象。您可以将下面的“this.objectExists”函数(这是我实现的)替换为ObjectVisible

    public void scrollDown(String identifier, String m){
            Boolean readyStateComplete = false;
            int i=0;

            while (!readyStateComplete) {
                    JavascriptExecutor js = (JavascriptExecutor)driver;
                    js.executeScript("window.scrollTo(0,Math.max(document.documentElement.scrollHeight," +
                                                     "document.body.scrollHeight,document.documentElement.clientHeight));");
                    covlog.logIssue(CovLogger.DEBUG, "scrollDown","Scrolling for the " + ++i + " times");
                    String tmp = js.executeScript("return document.readyState").toString();

                readyStateComplete = tmp.contentEquals("complete");
                //In case the object doesn't exists, break out of the loop
                //the object might represent a spinner that shows that more
                // records are downloaded.
                if ((i%24)==0){ //24 is page size
                        if (!this.objectExists(identifier, m)){
                            readyStateComplete = true;
                        }
                    }
            }
    }