- import org.openqa.selenium.By;
( Q- s7 x$ Z. u1 g& B% n
- import org.openqa.selenium.WebDriver;
- import org.openqa.selenium.WebElement;
- t) h4 H9 v7 a3 Q: v
- import org.openqa.selenium.chrome.ChromeDriver;
- import org.openqa.selenium.chrome.ChromeOptions;
0 G% H' t5 L% Z5 F0 ?- j
-
2 \" ]$ {% O; T
- public class Main {
- public static void main(String[] args) {
) |" D0 N% G8 ?# f" y: K
- ChromeOptions options=new ChromeOptions();
- options.addArguments("--remote-allow-origins=*");
- WebDriver webDriver=new ChromeDriver(options);
- webDriver.get("https://www.baidu.com/");
- //定位元素
- //找到百度搜索框
- WebElement element = webDriver.findElement(By.cssSelector(".s_ipt"));
- //输入软件测试
- c6 [5 ?2 P/ O+ x
- element.sendKeys("软件测试");
-
# {7 f: o5 H+ {7 Z% L
- }
$ H- e1 d6 Q: [+ W; b7 p
- }
复制代码
& e" t: ^- E9 t( J4 }# I
2 }+ E7 _! q! f7 m" C7 w: H
我知道答案
回答被采纳将会获得 5 金钱 已有0人回答
|