Versions Compared


  • This line was added.
  • This line was removed.
  • Formatting was changed.


Code Block
package testing;

import static org.junit.Assert.*;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;

import com.hp.lft.sdk.*;
import com.hp.lft.sdk.web.*;
import com.hp.lft.verifications.*;

import unittesting.*;

public class LeanFtTest extends UnitTestClassBase {

    public LeanFtTest() {
        //Change this constructor to private if you supply your own public constructor

    public static void setUpBeforeClass() throws Exception {
        instance = new LeanFtTest();

    public static void tearDownAfterClass() throws Exception {

    public void setUp() throws Exception {

    public void tearDown() throws Exception {

    public void totalPriceTest() throws GeneralLeanFtException, InterruptedException {
    	//Launch Chrome and navigate to the online store application
    	Browser browser = BrowserFactory.launch(BrowserType.CHROME);

    	//Click the "Tablets" category 
    	Link tabletsLink = browser.describe(Link.class, new LinkDescription.Builder()
    	//Click a specific tablet
    	Image tabletElitePad = browser.describe(Image.class, new ImageDescription.Builder()
    	tabletElitePad.setDisplayName("Tablet ElitePad");;
    	//Add it to the cart
    	browser.describe(Button.class, new ButtonDescription.Builder()
    			.name("ADD TO CART").build()).click();
    	//Store its price
    	String tabletPrice = browser.describe(WebElement.class, new WebElementDescription.Builder()
    			.className("roboto-medium cart-total ng-binding").build()).getInnerText();

    	//Check out
    	browser.describe(Button.class, new ButtonDescription.Builder()
    			.className("roboto-medium ng-binding").build()).click();
    	//Verify that the total price presented in the purchase summary page, is exactly the price of the selected tablet
    	String totalPrice = browser.describe(WebElement.class, new WebElementDescription.Builder()
    			.className("roboto-medium totalValue ng-binding")
    			.innerText(new RegExpProperty("\\$.*")).build()).getInnerText();
    	Verify.areEqual(tabletPrice, totalPrice, "Verify total price");

After running successfully the Test Case successfully and generating the JUnit XML report (e.g., TEST-testing.LeanFtTest-success.xml), it can be imported to Xray (by using either by the REST API or through the Import Execution Results action within the Test Execution).