- import org.openqa.selenium.By;
- import org.openqa.selenium.WebDriver;
+ t L, {# {8 o9 T. D
- import org.openqa.selenium.WebElement;
- import org.openqa.selenium.chrome.ChromeDriver;
: R% X& {6 F# k* _& B; t+ N# r% _$ V
- import org.openqa.selenium.chrome.ChromeOptions;
) K2 J+ @/ P% L$ u9 `7 l
-
7 X) S8 c3 X3 A- I
- public class Main {
- public static void main(String[] args) {
& @; l. H/ A2 H& O
- ChromeOptions options=new ChromeOptions();
( M, b& H+ P! i$ F4 u3 B. L
- options.addArguments("--remote-allow-origins=*");
& k( f8 y, M) Y- F. M
- WebDriver webDriver=new ChromeDriver(options);
- webDriver.get("https://www.baidu.com/");
, _, X9 ]4 Z8 a& Q- X( S
- //定位元素
, |/ h& S6 [ ~/ f4 H# z
- //找到百度搜索框
- WebElement element = webDriver.findElement(By.cssSelector(".s_ipt"));
- //输入软件测试
- element.sendKeys("软件测试");
-
- }
- }
复制代码
1 f. K2 V h2 W# o. C( g5 Y- g3 u0 v% P/ u3 ^/ k
我知道答案
回答被采纳将会获得 5 金钱 已有0人回答
|