回答

收藏

技术问答测试

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

  1. import org.openqa.selenium.By;
  2. import org.openqa.selenium.WebDriver; * K2 o% h. ]3 r# ?+ r& w+ ]
  3. import org.openqa.selenium.WebElement; $ K1 J5 ?! u& X
  4. import org.openqa.selenium.chrome.ChromeDriver;
  5. import org.openqa.selenium.chrome.ChromeOptions; ( g# v; E) K, E4 [1 X# h
  6. public class Main {
  7.     public static void main(String[] args) {
  8.         ChromeOptions options=new ChromeOptions();
  9.         options.addArguments("--remote-allow-origins=*"); + J' |8 a( i# e$ |* c+ {, X
  10.         WebDriver webDriver=new ChromeDriver(options);
  11.         webDriver.get("https://www.baidu.com/"); 7 l6 |, t' U' a3 ^* O" D
  12.         //定位元素 " {( S; Q+ t  a- u4 C& Z5 j
  13.         //找到百度搜索框
  14.        WebElement element = webDriver.findElement(By.cssSelector(".s_ipt"));
  15.        //输入软件测试 3 q5 s; D! ^% R' _3 s
  16.         element.sendKeys("软件测试"); ' |8 |. J! ~; p# n* d
  17.     }
  18. }
复制代码

/ c" O/ d& @6 G! H, R3 K0 t& \4 u3 ~4 i0 W2 _
我知道答案 回答被采纳将会获得5 金钱 已有0人回答
分享到:
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则