Код: Выделить всё
package org.example;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxOptions;
import org.openqa.selenium.support.ui.Wait;
import org.openqa.selenium.support.ui.WebDriverWait;
import java.time.Duration;
public class SeleniumDriver {
public static void main(String[] args) throws InterruptedException {
// compatible with Selenium 4.24.0
FirefoxOptions options = new FirefoxOptions();
options.addArguments("-headless");
WebDriver driver = new FirefoxDriver(options);
// logging in on the router web page
driver.get("http://192.168.0.1/webpages/index.html#/login");
Wait wait = new WebDriverWait(driver, Duration.ofSeconds(5));
WebElement password = wait.until(webDriver -> driver.findElement(By.xpath("//input[@type='password']")));
WebElement loginBtn = wait.until(webDriver -> driver.findElement(By.xpath("//button[@class='login-btn']")));
password.sendKeys("");
loginBtn.click();
wait.until(webDriver -> driver.findElement(By.xpath("//div[@data='advancedTopMenuBtn']")));
// continue interaction
driver.quit();
}
}
Не удалось найти решение этой проблемы, я пришел к выводу, что Selenium просто не предоставляет мобильные драйверы для запуска автономных автоматических сценариев, упакованных как приложения на реальном устройстве Android. Итак, вопрос тот же, что и в названии этой темы: как я могу автоматизировать взаимодействие мобильного веб-браузера на реальном устройстве Android? Подскажите, пожалуйста, возможные решения этой проблемы (если они существуют).
Подробнее здесь: https://stackoverflow.com/questions/790 ... oid-device
Мобильная версия