硒 2.25、火狐、OSX ML。
我让 Selenium 单击具有 Ajax 影响的按钮。
然后我想与结果进行交互。如果没有下面的睡眠,我会收到点击失败的错误,因为它无法将点击目标滚动到视图中。我不明白。这是怎么回事?
WebElement sampleComboInput = driver.findElement(By.id("sampleCombo-inputEl"));
sampleComboInput.click();
sampleComboInput.sendKeys("English-03.txt");
sampleComboInput.sendKeys(Keys.TAB, Keys.TAB);
WebElement goButton = driver.findElement(By.id("inputDialogGoButton-btnInnerEl"));
goButton.click();
WebElement resultsSpan = driver.findElement(By.cssSelector("span.ne-type-node.PERSON"));
assertTrue(resultsSpan.isDisplayed());
assertEquals("PERSON (3)", resultsSpan.getText());
WebElement parent = resultsSpan.findElement(By.xpath(".."));
Thread.sleep(5000); // without sleep, get error unable to scroll
Actions action = new Actions(driver);
action.doubleClick(parent);
action.perform();