2018-11-13 idea入门

在线导入

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>

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • Android 自定义View的各种姿势1 Activity的显示之ViewRootImpl详解 Activity...
    passiontim阅读 175,738评论 25 709
  • 用两张图告诉你,为什么你的 App 会卡顿? - Android - 掘金 Cover 有什么料? 从这篇文章中你...
    hw1212阅读 14,486评论 2 59
  • 回想起上高中时,作业很多,晚上睡觉很晚,早晨还要早起去跑操。从早晨的第二节课开始,就开始困得睁不开眼睛。老师在台上...
    春花望露阅读 1,254评论 0 0
  • 每个人都在努力着,以自己的方式 总有人,从自己的视角出发,得出结论: 有些人在努力,有些人则否。 然而,实际上,每...
    大大大傻琪阅读 3,655评论 0 0
  • 今夜你为我点灯 昏黄的灯光拉长的斜影 模糊的双眼 看不清你的轮廓 伸手想去触及 空空如也 闭上眼睛 却怎么也想不起...
    yu菇凉阅读 1,813评论 0 0