0


IDEA+Java+selenium+Testng安装配置

1.根据谷歌版本下载chromedriver

http://chromedriver.storage.googleapis.com/index.html

2.IDEA新建maven项目

引入jar包:

maven仓库地址:https://mvnrepository.com/

搜索selenium-java、testng

pom.xml加入:

<dependency>
    <groupId>org.seleniumhq.selenium</groupId>
    <artifactId>selenium-java</artifactId>
    <version>4.4.0</version>
</dependency>
<dependency>
    <groupId>org.testng</groupId>
    <artifactId>testng</artifactId>
    <version>7.6.1</version>
    <scope>test</scope>
</dependency>

Test.java:

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

public class Test {
    public static void main(String[] args) throws InterruptedException {
        System.setProperty("webdriver.chrome.driver", "E:/javaSoft/selenium/chromedriver.exe");
        WebDriver driver = new ChromeDriver();
        driver.manage().window().maximize();//全屏
        driver.get("http://localhost:8080/XXX/");//打开网址
        driver.findElement(By.name("username")).sendKeys("000231");
        driver.findElement(By.name("password")).sendKeys("11");
        Thread.sleep(1000);
        //driver.findElement(By.name("password")).sendKeys(Keys.ENTER);//通过Enter登录
        driver.findElement(By.id("loginForm")).submit();//通过提交form表单登录
    }
}

本文转载自: https://blog.csdn.net/MyHelloWord_/article/details/127005155
版权归原作者 染指了微凉 所有, 如有侵权,请联系我们删除。

“IDEA+Java+selenium+Testng安装配置”的评论:

还没有评论