怎么在手机上建网站,wordpress 当前分类id,重庆网站界面设计,网站手机端怎么做目录
1.前言
2.鼠标点击
2.1click点击对象
2.2senk_keys在对象上模拟键盘输入
2.3清除对象输入的文本内容
2.4submit提交
2.5 text用于获取文本信息
编辑3.获取信息
3.1获取title
3.2获取url 1.前言
前面我们讲了如何定位元素,那么我们把元素定位到了以后,又如何…
目录
1.前言
2.鼠标点击
2.1click点击对象
2.2senk_keys在对象上模拟键盘输入
2.3清除对象输入的文本内容
2.4submit提交
2.5 text用于获取文本信息
编辑3.获取信息
3.1获取title
3.2获取url 1.前言
前面我们讲了如何定位元素,那么我们把元素定位到了以后,又如何进行操作呢?这篇博客我们会分几个模块来详细的介绍这些操作.如何的去操作测试对象
2.鼠标点击
2.1click点击对象
我们还是用百度距离,我们点击新闻按钮. public static void main(String[] args) {WebDriver webDriver new ChromeDriver();webDriver.get(https://www.baidu.com);webDriver.findElement(By.cssSelector(#s-top-left a:nth-child(1))).click();}
通过代码获取到了.
当我们运行代码以后, 2.2senk_keys在对象上模拟键盘输入
我们在搜索框输入我们需要的东西.
private static void test2() {WebDriver webDriver new ChromeDriver();webDriver.get(https://www.baidu.com);webDriver.findElement(By.cssSelector(#kw)).sendKeys(selenium);} 2.3清除对象输入的文本内容
private static void test3() throws InterruptedException {WebDriver webDriver new ChromeDriver();webDriver.get(https://www.baidu.com);webDriver.findElement(By.cssSelector(#kw)).sendKeys(selenium);// webDriver.manage().timeouts().implicitlyWait(3, TimeUnit.MINUTES);sleep(3000);webDriver.findElement(By.cssSelector(#kw)).clear();} 这里加入了一个死锁,可以方便我们看到效果.
2.4submit提交
//提交private static void test4() {WebDriver webDriver new ChromeDriver();webDriver.get(https://www.baidu.com);webDriver.findElement(By.cssSelector(#kw)).sendKeys(selenium);webDriver.findElement(By.cssSelector(#su)).submit();}
在提交了以后可以看到已经搜索出来了. 2.5 text用于获取文本信息
我们来获取百度上的新闻一个信息 private static void test5() throws InterruptedException {WebDriver webDriver new ChromeDriver();webDriver.get(https://www.baidu.com);String str webDriver.findElement(By.cssSelector(#hotsearch-content-wrapper li:nth-child(1) a span.title-content-title)).getText();sleep(3000);System.out.println(str);}
3.获取信息
3.1获取title private static void test6() throws InterruptedException {WebDriver webDriver new ChromeDriver();webDriver.get(https://www.baidu.com);sleep(2000);System.out.println(webDriver.getTitle());} 3.2获取url private static void test7(){WebDriver webDriver new ChromeDriver();webDriver.get(https://www.baidu.com);System.out.println(webDriver.getCurrentUrl());}