I have created a which is as follows:

@(priority = 61)
public void Schedule_Valid_Promocode_Discount () throws InterruptedException
{
    WebElement Discount = driver.findElement(By.xpath("html/body/max-app-root/max-schedule/div/div[2]/max-campaign-information/div/aside/div[2]/div[3]/div/div[3]/div[2]/h4"));
    Assert.assertTrue(Discount!=null); // Check if discount appeared
    Assert.assertEquals("RM 1,000", Discount.getText());
}
public WebElement getSchedule_Discount_Amount () throws InterruptedException
{
    WebElement Discount = driver.findElement(By.xpath("html/body/max-app-root/max-schedule/div/div[2]/max-campaign-information/div/aside/div[2]/div[3]/div/div[3]/div[2]/h4"));
     Discount;
}

I’m trying to this value so that I can test the same value in upcoming test . The test is as follows:

@Test(priority = 79)
public void BillingDetail_InvoiceTab_DiscountAmount () throws InterruptedException
{
    //Check Discount amount on billing detail page
    WebElement InvoiceDiscount = driver.findElement(By.xpath("html/body/max-app-root/max-summary/div/div/div[2]/div/div/mat-card/mat-card-content/div[1]/div[1]/div/p[2]/span"));
    WebElement Discount = this.getSchedule_Discount_Amount();
    Assert.assertEquals(Discount.getText(), InvoiceDiscount.getText());
}

When I try to call this.getSchedule_Discount_Amount(); I get error – unable to locate element.

I have only one class and all my test cases falls under same class. I’m new to automation testing and not sure in what scenerios a new class should be created.



Source link https://sqa.stackexchange.com/questions/34388/is-it-possible-to-store-value-return-it-and--in-another-test-case-by-ca

LEAVE A REPLY

Please enter your comment!
Please enter your name here