Экран первой ошибки
Экран второй ошибки
Я выполняю пример кода селена:
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.WebDriverWait;
import static org.openqa.selenium.support.ui.ExpectedConditions.presenceOfElementLocated;
import java.time.Duration;
public class HelloSelenium {
public static void main(String[] args) {
WebDriver driver = new FirefoxDriver();
WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(10));
try {
driver.get("https://google.com/ncr");
driver.findElement(By.name("q")).sendKeys("cheese" + Keys.ENTER);
WebElement firstResult = wait.until(presenceOfElementLocated(By.cssSelector("h3>div")));
System.out.println(firstResult.getAttribute("textContent"));
} finally {
driver.quit();
}
}
}
И получение ошибок, как показано на скриншотах выше.
Обратите внимание, что действие выполняется, но последний оператор в блоке try не печатает атрибут firstElement. Я понимаю, что проблему не очень легко прочитать, но ее решение должно быть интересным.
Также я использую geckodriver (для Firefox) в Манджаро.
И я использую gradle.