<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.alatus</groupId> <artifactId>Kill</artifactId> <version>0.0.1-SNAPSHOT</version> <name>Kill</name> <description>Kill</description> <url/> <licenses> <license/> </licenses> <developers> <developer/> </developers> <scm> <connection/> <developerConnection/> <tag/> <url/> </scm> <properties> <java.version>21</java.version> </properties> <dependencies> <dependency> <groupId>org.seleniumhq.selenium</groupId> <artifactId>selenium-java</artifactId> <version>4.19.1</version> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>21</source> <target>21</target> </configuration> </plugin> </plugins> </build> </project><?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.alatus</groupId> <artifactId>Kill</artifactId> <version>0.0.1-SNAPSHOT</version> <name>Kill</name> <description>Kill</description> <url/> <licenses> <license/> </licenses> <developers> <developer/> </developers> <scm> <connection/> <developerConnection/> <tag/> <url/> </scm> <properties> <java.version>21</java.version> </properties> <dependencies> <dependency> <groupId>org.seleniumhq.selenium</groupId> <artifactId>selenium-java</artifactId> <version>4.19.1</version> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>21</source> <target>21</target> </configuration> </plugin> </plugins> </build> </project>
package com.alatus.jiuxingxing; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.chrome.ChromeOptions; import org.openqa.selenium.support.ui.ExpectedConditions; import org.openqa.selenium.support.ui.WebDriverWait; import java.time.Duration; public class ScriptApplication { public static void main(String[] args) { System.setProperty("webdriver.chrome.driver", "D:\\chromedriver-win64\\chromedriver.exe"); ChromeOptions options = new ChromeOptions(); options.addArguments("--remote-allow-origins=*"); // 初始化WebDriver WebDriver webDriver = new ChromeDriver(options); webDriver.get(""); // 定位用户名输入框 WebDriverWait wait = new WebDriverWait(webDriver, Duration.ofSeconds(10)); WebElement usernameField = wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("input[data-automation-id='uname']"))); usernameField.sendKeys("asdasd"); // 定位密码输入框 WebElement passwordElement = webDriver.findElement(By.cssSelector("input[data-automation-id='pwd']")); passwordElement.sendKeys("123456"); // 定位并点击“登录”按钮 WebElement loginButton = webDriver.findElement(By.xpath("//span[text()='登录']")); loginButton.click(); // webDriver.navigate().refresh(); // 刷新页面以准备下一次循环 } }package com.alatus.jiuxingxing; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.chrome.ChromeOptions; import org.openqa.selenium.support.ui.ExpectedConditions; import org.openqa.selenium.support.ui.WebDriverWait; import java.time.Duration; public class ScriptApplication { public static void main(String[] args) { System.setProperty("webdriver.chrome.driver", "D:\\chromedriver-win64\\chromedriver.exe"); ChromeOptions options = new ChromeOptions(); options.addArguments("--remote-allow-origins=*"); // 初始化WebDriver WebDriver webDriver = new ChromeDriver(options); webDriver.get(""); // 定位用户名输入框 WebDriverWait wait = new WebDriverWait(webDriver, Duration.ofSeconds(10)); WebElement usernameField = wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("input[data-automation-id='uname']"))); usernameField.sendKeys("asdasd"); // 定位密码输入框 WebElement passwordElement = webDriver.findElement(By.cssSelector("input[data-automation-id='pwd']")); passwordElement.sendKeys("123456"); // 定位并点击“登录”按钮 WebElement loginButton = webDriver.findElement(By.xpath("//span[text()='登录']")); loginButton.click(); // webDriver.navigate().refresh(); // 刷新页面以准备下一次循环 } }

7120

被折叠的 条评论
为什么被折叠?



