回答

收藏

技术问答测试

技术问答 技术问答 724 人阅读 | 0 人回复 | 2023-08-08

  1. import org.openqa.selenium.By; ( Q- s7 x$ Z. u1 g& B% n
  2. import org.openqa.selenium.WebDriver;
  3. import org.openqa.selenium.WebElement; - t) h4 H9 v7 a3 Q: v
  4. import org.openqa.selenium.chrome.ChromeDriver;
  5. import org.openqa.selenium.chrome.ChromeOptions; 0 G% H' t5 L% Z5 F0 ?- j
  6. 2 \" ]$ {% O; T
  7. public class Main {
  8.     public static void main(String[] args) { ) |" D0 N% G8 ?# f" y: K
  9.         ChromeOptions options=new ChromeOptions();
  10.         options.addArguments("--remote-allow-origins=*");
  11.         WebDriver webDriver=new ChromeDriver(options);
  12.         webDriver.get("https://www.baidu.com/");
  13.         //定位元素
  14.         //找到百度搜索框
  15.        WebElement element = webDriver.findElement(By.cssSelector(".s_ipt"));
  16.        //输入软件测试 - c6 [5 ?2 P/ O+ x
  17.         element.sendKeys("软件测试");
  18. # {7 f: o5 H+ {7 Z% L
  19.     } $ H- e1 d6 Q: [+ W; b7 p
  20. }
复制代码

& e" t: ^- E9 t( J4 }# I
2 }+ E7 _! q! f7 m" C7 w: H
我知道答案 回答被采纳将会获得5 金钱 已有0人回答
分享到:
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则