zoukankan      html  css  js  c++  java
  • selenium demo(三)

    (三)删除

     1 package test;
     2 
     3 
     4 import org.openqa.selenium.*;
     5 import org.openqa.selenium.chrome.ChromeDriver;
     6 import org.openqa.selenium.interactions.Actions;
     7 import org.testng.annotations.Test;
     8 import java.util.concurrent.TimeUnit;
     9 
    10 
    11 public class AutoTestThree {
    12     @Test
    13         public void test() throws InterruptedException{
    14         System.setProperty("webdriver.chrome.driver","D:/selenium-drivers/chromedriver.exe");
    15         WebDriver webDriver = new ChromeDriver();
    16         webDriver.manage().window().maximize();
    17         webDriver.get("http://xxx.xxx.xxx.xxx:xxxx/xxx");
    18         webDriver.manage().timeouts().implicitlyWait(2, TimeUnit.SECONDS);
    19         //登录
    20         webDriver.findElement(By.id("loginUser.id")).sendKeys("xxxxxx");
    21         webDriver.findElement(By.id("loginUser.pass")).sendKeys("xxxxxx");
    22         webDriver.findElement(By.className("submitLink")).click();
    23         webDriver.findElement(By.xpath("//*[@id='guard-base']/a")).click();
    24         webDriver.findElement(By.xpath("//*[@id='guard-base']/ul/li[1]/a")).click();
    25         webDriver.switchTo().frame("main-frame");
    26         //请输入职业打假人姓名...
    27         webDriver.findElement(By.xpath("//*[@id='searchObj']")).sendKeys("test");
    28         Thread.sleep(2000);
    29         //选择行业
    30         webDriver.findElement(By.xpath("//*[@id='industrySpan-myselect-tree']")).click();
    31         WebElement el1 = webDriver.findElement(By.xpath("//*[@id='industrySpan-myselect-tree']/div/ul/li[1]/div/span[1]"));
    32         WebElement el2 = webDriver.findElement(By.xpath("//*[@id='industrySpan-myselect-tree']/div/ul/li[1]/ul/li[1]/div/span[2]"));
    33         WebElement el3 = webDriver.findElement(By.xpath("//*[@id='industrySpan-myselect-tree']/div/ul/li[1]/ul/li[1]/ul/li[1]/div/span[3]"));
    34         WebElement el4 = webDriver.findElement(By.xpath("//*[@id='industrySpan-myselect-tree']/div/ul/li[1]/ul/li[1]/ul/li[1]/ul/li[1]/div/span[4]"));
    35         Actions action = new Actions(webDriver);
    36 
    37         action.moveToElement(el1).click().perform();
    38         action.moveToElement(el2).click().perform();
    39         action.moveToElement(el3).click().perform();
    40         action.moveToElement(el4).click().perform();
    41 
    42 
    43         Thread.sleep(1000);
    44 
    45         webDriver.findElement(By.cssSelector(".search")).findElement(By.cssSelector(".search_icon")).click();
    46         Thread.sleep(1500);
    47         webDriver.findElement(By.xpath("//button[@class='search'and text()='重置']")).click();
    48 
    49 
    50 
    51         Thread.sleep(1000);
    52 
    53         webDriver.quit();
    54     }
    55 }
  • 相关阅读:
    Java第十三天,内部类
    Java第十二天,权限修饰符
    Java面向对象基础
    opencv配置(win10+VS2015+opencv3.1)
    malloc函数
    C++用new创建对象和不用new创建对象的区别解析
    字符串匹配KMP算法中Next[]数组和Nextval[]数组求法
    C++将一个数组内容赋给另一个数组
    C++中的const和指针组合
    通过图片对比带给你不一样的KMP算法体验
  • 原文地址:https://www.cnblogs.com/drnmmond/p/7473038.html
Copyright © 2011-2022 走看看