• 软件测试第四次作业


     

    第一步:给实验5原登录页面表单代码加上id属性

    <html>

        <head><title>用户登录</title></head>

        <body>

            <form action="validate.jsp" method="post">

                <div align="center">

                用户登录<br>

                用户名:<input id="un" type="text" name="username"><br><br>

                密码:<input id="pw" type="text" name="password"><br><br>

                <input type="submit" id="sm" value="登录">

                </div>

            </form>

        </body>

    </html>

     第二步:往数据库添加自己的账户数据

    alter table user;

    insert into user values(8,‘zch,‘033‘);

     第三步:测试程序代码

    import org.junit.Test;

    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.ie.InternetExplorerDriver;

    import org.openqa.selenium.support.ui.WebDriverWait;

    public class SeleniumTest{

        /*

        *功能:利用Selenium2为Lab05项目中的登录功能实现功能自动化测试

        */

        @Test

        public void Demo(){     

            System.setProperty("webdriver.firefox.bin", "D:\Program Files\fire\firefox.exe");

            WebDriver demo = new FirefoxDriver();

     demo.get("http://localhost:8080/Lab05/login.jsp");

    WebDriverWait wait = new WebDriverWait(driver, 90);

            WebElement txtSearchBox = demo.findElement(By.name("un")).sendKeys("zch");

            WebElement txtSearchBox = demo.findElement(By.name("pw")).sendKeys("0123456");

            WebElement btn = demo.findElement(By.id("su")).click();

            //demo.close();      

        }      

  • 相关阅读:
    MVC4中Ajax.BeginForm OnSuccess 不执行以及控制器返回JsonResult 提示下载的原因
    string.Equals 比较2个字符串是否相同忽略大小写
    [转载]mvc使用JsonResult返回Json数据
    [转载]深入理解ASP.NET MVC之ActionResult
    [转载]自定义ASP.NET MVC Html辅助方法 TagBuilder
    [转载]AOP面向方面编程
    [转载]ASP.NET MVC 3的分部视图
    适配 iOS尺寸
    IOS Bug分析
    苹果一些乱七八糟流程整理
  • 原文地址:https://www.cnblogs.com/LJQ4228/p/5536814.html
Copyright © 2020-2023  润新知