• 作业1

    作业2

  • 作业3

  • 作业2

  • 作业1

  • 老师,我在mac上执行以下命令时报错,我在老师的命令后加了两个参数allowPublicKeyRetrieval=true&serverTimezone=UTC

    docker run -d  --name sonarqube_vip \
    -p 9000:9000 -p 9092:9092 \
    --link sonar-mysql:db \
    -e SONARQUBE_JDBC_USERNAME=sonar \
    -e SONARQUBE_JDBC_PASSWORD=sonar \
    -e SONARQUBE_JDBC_URL="jdbc:mysql://db:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance&useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=UTC" \
    sonarqube

    看出错的log是table已经存在,怎么解决?我很困惑为什么表已经存在了,我是新创建的sonar-mysql容器

  • 作业2

    public Response delete(String id){
    return given().log().all().
    queryParam("access_token",Wework.getToken())
    .queryParam("id",id).
    when().get("https://qyapi.weixin.qq.com/cgi-bin/department/delete").
    then().log().all().extract().response();

    }

    public Response update(String id,String name,String pid){
    String body=JsonPath.parse(this.getClass().getResourceAsStream("/data/update.json")).set("$.id",id).set("name",name).set("parentid",pid).jsonString();
    return
    given().log().all().
    queryParam("access_token",Wework.getToken())
    .body(body).
    when().post("https://qyapi.weixin.qq.com/cgi-bin/department/update")
    .then().log().all().statusCode(200).extract().response();
    }
    @Test
    public void delete(){
    String id=department.create("dev4","5").then().statusCode(200).extract().response().getBody().path("id").toString();
    System.out.println(id);
    department.delete(id).
    then().statusCode(200).
    body("errcode",equalTo(0)).
    body("errmsg",equalTo("deleted"));
    }

    @Test
    public void update(){
    String id=department.create("dev5","5").then().statusCode(200)
    .extract().response().getBody().path("id").toString();

    department.update(id,"test1","5").
    then().statusCode(200).
    body("errcode",equalTo(0)).
    body("errmsg",equalTo("updated"));
    }

    数据模版

    {
    "id": 2,
    "name": "广州研发中心",
    "parentid": 1,
    "order": 1
    }
  • package wework.contact;

    import io.restassured.response.Response;
    import wework.Wework;



    import static io.restassured.RestAssured.given;

    public class Department {

    public Response list(String id){
    return given().log().all().param("access_token", Wework.getToken())
    .param("id",id)
    .when().get("https://qyapi.weixin.qq.com/cgi-bin/department/list")
    .then().log().all().statusCode(200).extract().response();
    }
    }

    import org.junit.jupiter.api.Test;
    import wework.contact.Department;

    import static org.hamcrest.core.IsEqual.equalTo;

    public class DepartmentTest {
    @Test
    public void list(){
    Department department=new Department();
    department.list("4").
    then().statusCode(200).
    body("department[0].name",equalTo("测试部"))
    .body("department[0].id",equalTo(4));
    }
    }

  • Docker 实战 at March 09, 2019

    作业五

  • Docker 实战 at March 08, 2019

    练习二

    练习三

    练习四

  • 作业:
    Git hub地址 https://github.com/hy-dream/Selenium.git

    测试用例

    package BusinessLogic;

    import org.openqa.selenium.By;
    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.chrome.ChromeDriver;
    import org.openqa.selenium.chrome.ChromeOptions;
    import org.testng.Assert;
    import org.testng.annotations.AfterMethod;
    import org.testng.annotations.BeforeMethod;
    import org.testng.annotations.Test;
    import page.HomePage;
    import page.TeamPage;

    import javax.swing.plaf.PanelUI;
    import java.util.concurrent.TimeUnit;

    public class OpenTeam {
    WebDriver driver;

    @BeforeMethod
    public void before(){
    System.getProperty("user.dir");
    String path="\\src\\test\\drivers\\chromedriver.exe";
    System.setProperty("webdriver.chrome.driver",System.getProperty("user.dir")+path);
    ChromeOptions options=new ChromeOptions();
    options.addArguments("--user-data-dir=C:/Users/Administrator/AppData/Local/Google/Chrome/User Data/Default");
    driver=new ChromeDriver(options);
    driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
    }

    @Test
    public void OpenTeamWithoutLogin(){
    driver.get("https://testerhome.com");
    TeamPage teamPage=new HomePage(driver).gotoTeams().gotoTeamPage("霍格沃兹测试学院");
    teamPage.clickTopic("定向班第一期_Selenium 入门实战_20190217");
    String actual=driver.findElement(By.cssSelector("div.alert")).getText();
    Assert.assertEquals(actual,"访问被拒绝,你可能没有权限或未登录。");
    }

    @AfterMethod
    public void after(){
    driver.quit();
    }
    }

    PO NavBarPage 添加gotoTeams方法

    public TeamsPage gotoTeams(){
    teams.click();
    WebDriverWait wait=new WebDriverWait(driver,10);
    wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("hot_teams")));
    return new TeamsPage(driver);
    }

    PO TeamsPage

    package page;

    import com.sun.xml.internal.ws.policy.AssertionSet;
    import org.openqa.selenium.By;
    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.support.FindBy;
    import org.openqa.selenium.support.ui.ExpectedConditions;
    import org.openqa.selenium.support.ui.WebDriverWait;
    import org.testng.Assert;

    public class TeamsPage extends NavBarPage{
    WebDriver driver;


    public TeamsPage(WebDriver driver){
    super(driver);
    this.driver=driver;
    }

    public TeamPage gotoTeamPage(String name){
    driver.findElement(By.linkText(name)).click();
    WebDriverWait wait=new WebDriverWait(driver,10);
    wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("h1.media-heading")));
    String actualTeam=driver.findElement(By.cssSelector("h1.media-heading")).getText();
    Assert.assertTrue(actualTeam.contains(name));
    return new TeamPage(driver);
    }
    }

    PO TeamPage

    package page;

    import org.openqa.selenium.By;
    import org.openqa.selenium.WebDriver;

    public class TeamPage extends NavBarPage {

    WebDriver driver;
    public TeamPage(WebDriver driver){
    super(driver);
    this.driver=driver;
    }

    public void clickTopic(String title){
    driver.findElement(By.xpath("//a[@title=\""+title+"\"]")).click();
    }
    }