zoukankan      html  css  js  c++  java
  • java工作复习——单选下拉列表——检查单选列表的选项文字是否符合期望

    package jkcs;
    
    import java.util.ArrayList;
    import java.util.Arrays;
    import java.util.List;
    
    import org.openqa.selenium.By;
    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.WebElement;
    import org.openqa.selenium.firefox.FirefoxDriver;
    import org.openqa.selenium.interactions.Actions;
    import org.openqa.selenium.support.ui.Select;
    
    public class jdcs 
    {
        
        public static void main(String[] args) throws InterruptedException 
        {
            System.setProperty("webdriver.chrome.bin","‪C:\Program Files (x86)\Mozilla Firefox\firefox.exe");    //设置安装路径,防止系统找不到
            
            WebDriver driver = new FirefoxDriver();        //初始化FireFox浏览器实例,并打开浏览器
    
            driver.manage().window().maximize();         //最大化窗口  
            
            
            
            driver.get("http://www.baidu.com");    //打开一个网址,方法一
            
            Thread.sleep(8000);
            
            
            
            
            
            
            Actions action = new Actions(driver);
            
            
            action.moveToElement(driver.findElement(By.linkText("设置"))).perform();     //鼠标悬浮在 设置  元素上面
            
            driver.findElement(By.className("setpref")).click();      // 打开搜索设置
            
            
            Thread.sleep(8000);
            
            
            
           
            List<String> expect_options = Arrays.asList( new String[]{"每页显示10条","每页显示20条","每页显示50条"});
            
            
            
            
            
            Select dropList = new Select(driver.findElement(By.name("NR")));
            
            List<String> actual_option = new ArrayList<String>();
            
            for ( WebElement option:dropList.getOptions() )
                actual_option.add(option.getText());
            
            Assert.assertEquals(expect_options.toArray(),actual_option.toString());
    
            
            
            Thread.sleep(8000);
            
    
            driver.quit();
        }
    }
  • 相关阅读:
    (大数 小数点) 大明A+B hdu1753
    (大数 万进制) N! hdu1042
    (next_permutation) 排列2 hdu 1716
    (set)产生冠军 hdu2094
    (Set) {A} + {B} hdu1412
    (set stringstream)单词数 hdu2072
    (set)MG loves gold hdu6019
    (set) 人见人爱A-B hdu2034
    (map)水果 hdu1263
    (map)What Are You Talking About hdu1075
  • 原文地址:https://www.cnblogs.com/xiaobaibailongma/p/12745625.html
Copyright © 2011-2022 走看看