zoukankan      html  css  js  c++  java
  • junit4框架——webdriver脚本

    后续会带来testNG单元测试框架比junit框架更强大;

    package cn.helloselenium;
    import org.openqa.selenium.*;
    import org.openqa.selenium.firefox.FirefoxDriver;
    import org.openqa.selenium.By;
    
    
    import org.junit.After;
    import org.junit.AfterClass;
    import org.junit.Before;
    import org.junit.BeforeClass;
    import org.junit.Test;
    
    
    public class junitwebdriver {
        public WebDriver driver;
        String baseUrl="http://www.sogou.com/";
    
        @BeforeClass
        public static void setUpBeforeClass() throws Exception {
        }
    
        @AfterClass
        public static void tearDownAfterClass() throws Exception {
        }
    
        @Before
        public void setUp() throws Exception {
            System.setProperty("webdriver.gecko.driver", "C:\Program Files (x86)\Mozilla Firefox\geckodriver.exe");
            
            driver=new FirefoxDriver();
            
        }
    
        @After
        public void tearDown() throws Exception {
            //driver.quit();
        }
    
        @Test
        public void test() {
            //fail("Not yet implemented");
            driver.get(baseUrl+"/");
            driver.findElement(By.id("query")).sendKeys("junit4单元测试");
            driver.findElement(By.id("stb")).click();
        }
    
    }
  • 相关阅读:
    CSS发布时间
    1CSS简介
    CSS 样式的优先级(重要,一定要理解)
    css为什么叫层叠样式表
    Django学习手册
    Django学习手册
    Django学习手册
    Django学习手册
    Django学习手册
    Django学习手册
  • 原文地址:https://www.cnblogs.com/wangyinxu/p/6363090.html
Copyright © 2011-2022 走看看