zoukankan      html  css  js  c++  java
  • selenium+java项目实战---百度输入框

    最近对java+selenium+testng+maven 做一个小项目的总结,并对工作中的框架在做一些小总结,大概目录为:

    1.项目实战--百度登录输入框

    2.项目的二次封装

    3.框架分层,及po模式

    4.框架中的监听及重跑

    项目实战:

    百度输入框,目录格式:

    package test.jun;
    
    import org.openqa.selenium.By;
    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.chrome.ChromeDriver;
    
    import junit.framework.Assert;
    
    public class login {
        public static void main(String[] args) {
            System.setProperty("webdriver.chrome.driver", "chromedriver.exe");
            WebDriver driver = new ChromeDriver();
            driver.get("http://www.baidu.com");
            driver.findElement(By.linkText("登录")).click();
            try {
                Thread.sleep(3000);
            } catch (InterruptedException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }                                                                                                                                                                    
            driver.findElement(By.id("TANGRAM__PSP_10__footerULoginBtn")).click();
            driver.findElement(By.id("TANGRAM__PSP_10__userName")).clear();
            driver.findElement(By.id("TANGRAM__PSP_10__userName")).sendKeys("18582559217");
            driver.findElement(By.id("TANGRAM__PSP_10__password")).clear();
            driver.findElement(By.id("TANGRAM__PSP_10__password")).sendKeys("2222222222");
            driver.findElement(By.id("TANGRAM__PSP_10__submit")).click();
            //因为有验证码,我们以出现验证码为准,做为断言
            if(driver.findElement(By.id("TANGRAM__PSP_10__error")).isDisplayed()) {
                System.out.println("登录成功");
            }else {
                Assert.fail("断言失败");
            }
            
        }
    }

  • 相关阅读:
    UIApplication直接应用
    iOS开发之苹果开发者账号注册申请流程
    iOS开发之蓝牙使用-建立连接的
    Swift3.0 UICollectionView简单使用
    CSS网页菜单
    c#qq发邮件
    多文档界面的实现(DotNetBar的superTabControl)
    CE修改器:外挂制作高级技巧
    MariaDB 库的基本操作
    Python-使用PyQT生成图形界面
  • 原文地址:https://www.cnblogs.com/chongyou/p/10335366.html
Copyright © 2011-2022 走看看