美文网首页
2018-11-13 idea入门

2018-11-13 idea入门

作者: deji_Chen | 来源:发表于2018-11-13 17:20 被阅读0次

    在线导入

    image.png
    image.png
    image.png

    工程操作

    image.png

    新建方法使用

    image.png testNG

    GuoyaLogin

    package com.guoyasoft.autoUI.guoya_1810;//引入java代码路径
    
    import com.guoyasoft.autoUI.common.BaseUI;
    import org.openqa.selenium.By;
    import org.testng.annotations.Test;
    
    public class GuoyaLogin extends BaseUI {
    
      //publie  公开的方法  void 无返回 login()方法名
      //添加testng注解用来执行测试方法
      @Test
      public void login() {
        driver.get("http://47.98.226.232:8080/guoya-medium/jsp/user/login.jsp");
        sleep(1000);//添加等待时间
    
        driver.findElement(By.name("userName")).clear();//查找元素根据name查找  然后执行清除
    
        driver.findElement(By.name("userName")).sendKeys("chen952");//查找元素根据name查找   然后执行输入
        sleep(1000);
    
        driver.findElement(By.id("password")).clear();//查找元素根据id查找  然后执行清除
    
        driver.findElement(By.id("password")).sendKeys("qweasd");//查找元素根据id查找  然后执行输入
        sleep(1000);
        driver.findElement(By.xpath("//input[@id='checkCode']")).sendKeys("12345");//根据xpath查找元素  执行输入
        sleep(1000);
        driver.findElement(By.xpath("//input[@id='loginBtn']")).click();//根据xpath查找元素  执行输入
    
      }
    
      @Test
      public void signup() {
        driver.get("http://47.98.226.232:8080/guoya-medium/jsp/user/signUp.jsp");
        sleep(1000);//添加等待时间
        driver.findElement(By.name("userName")).clear();//查找元素根据name查找  然后执行清除
    
        driver.findElement(By.name("userName")).sendKeys("chen952");//查找元素根据name查找   然后执行输入
        sleep(1000);
        driver.findElement(By.xpath("//input[@id='realName']")).sendKeys("比汗");//查找元素根据name查找   然后执行输入
        sleep(1000);
        driver.findElement(By.xpath("//input[@id='password']")).sendKeys("qweasd");
        sleep(1000);
        //查找元素根据name查找   然后执行输入
        driver.findElement(By.xpath("//input[@id='password2']")).sendKeys("qweasd");
        sleep(1000);
        //查找元素根据name查找   然后执行输入
        driver.findElement(By.xpath("//input[@id='phone']")).sendKeys("15185201479");
        sleep(1000);
        //查找元素根据name查找   然后执行输入
        driver.findElement(By.xpath("//input[@id='age']")).sendKeys("22");
        sleep(1000);
        //查找元素根据name查找   然后执行输入
        driver.findElement(By.xpath("//input[@id='checkCode']")).sendKeys("1234");
        sleep(1000);
        //查找元素根据name查找   然后执行输入
    
        driver.findElement(By.xpath("//input[@id='submitBtn']")).click();
        sleep(1000);
    
        driver.switchTo().alert().accept();
    
      }
    }
    

    GuoyaLogin.xml

    <!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
    <suite name="chendj">
        <test name="test0" preserve-order="true" enabled="true">
            <classes>
                <class name="com.guoyasoft.autoUI.guoya_1810.GuoyaLogin">
                    <methods>
                        <include name="signup" />
                        <include name="login" />
                    </methods>
                </class>
            </classes>
        </test>
    </suite>
    
    

    相关文章

      网友评论

          本文标题:2018-11-13 idea入门

          本文链接:https://www.haomeiwen.com/subject/uaekfqtx.html