- import org.openqa.selenium.By;
! P, R/ x+ n+ f' v' I
- import org.openqa.selenium.WebDriver;
- import org.openqa.selenium.WebElement;
- import org.openqa.selenium.chrome.ChromeDriver;
- import org.openqa.selenium.chrome.ChromeOptions;
-
7 ^7 |$ e4 k5 p# U0 `
- public class Main {
8 {, n% }" \" P1 |% X
- public static void main(String[] args) {
. q, E( e/ ~+ }$ \; n/ l( C+ X
- ChromeOptions options=new ChromeOptions();
- options.addArguments("--remote-allow-origins=*");
9 J. \$ V* k! x, M& g
- WebDriver webDriver=new ChromeDriver(options);
- webDriver.get("https://www.baidu.com/");
- //定位元素
- //找到百度搜索框
- WebElement element = webDriver.findElement(By.cssSelector(".s_ipt"));
) n3 }7 q4 ^ t6 Q, b
- //输入软件测试
- W* g( F. q, A0 ]$ j8 D$ F
- element.sendKeys("软件测试");
-
- }
) P7 k7 p% t: T6 w l
- }
复制代码
) u7 b+ D- ?; q1 c3 ]7 t
9 b- h+ Y7 s V* B! u3 Y! g
我知道答案
回答被采纳将会获得 5 金钱 已有0人回答
|