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();
        }
    }
  • 相关阅读:
    在前端眼中pc端和移动的开发区别
    两个对象的合并
    关于后台传来的json是含英文字母的string
    关于jquery的取消阻止默认事件
    练习:模态对话框
    JS之DOM节点增删改查与属性设置
    JS之DOM Event(事件)
    JS的DOM对象之DOM节点
    JS的history对象和location对象
    JS的BOM对象之window对象,利用window对象方法实现定时器
  • 原文地址:https://www.cnblogs.com/xiaobaibailongma/p/12745625.html
Copyright © 2011-2022 走看看