4.8节 购买商品抛出如下错误 望老师指教一二

来源:8-8 购买商品代码实战

AWMA

2019-04-04

fy3.login.testLogin() is depending on method public void fy3.login.getHomePage() throws java.lang.InterruptedException, which is not annotated with @Test or not included.

代码:
@Test
public void getHomePage() throws InterruptedException{
driver.get(“https://www.imooc.com/”);
Thread.sleep(3000);
//driver.findElement(By.id(“js-signin-btn”)).click();
}

@Test(dependsOnMethods={“getHomePage”})
public void testLogin() throws InterruptedException {
loginpro.login("812709259@qq.com","-----------");
}

/**
 * 获取课程信息
 * */
public String getCourseText(WebElement element){
    return element.getText();
}

/**
 * 下单流程
 * */

@Test(dependsOnMethods={“testLogin”})
public void buyCourse() throws InterruptedException {
driver.get(“https://coding.imooc.com/class/325.html”);
String courseDetail = driver.findElement(By.className(“path”)).findElement(By.tagName(“span”)).getText();
driver.findElement(By.id(“buy-trigger”)).click();
driver.findElement(By.linkText(“提交订单”)).click();
Thread.sleep(3000);
String orderText = driver.findElement(By.className(“order”)).getText();
if (orderText != null){
String orderString = driver.findElement(By.className(“item”)).findElement(By.className(“left”)).findElement(By.tagName(“dt”)).getText();
Assert.assertEquals(courseDetail,orderString,“购买的商品信息不一样”);
}

写回答

1回答

Mushishi

2019-04-05

代码看着没问题哈,但是给的错误是因为你依赖有问题。那么这里出错就是你第一个依赖没执行。就是系统认为没有这个case。你截图一下整个代码。然后你运行到什么样子出错。

0
0

Web自动化测试 Selenium基础到企业应用

零基础学习Web自动化,测试面试必问技术点解答,高薪在向你招手

1237 学习 · 862 问题

查看课程