Skip to content

Instantly share code, notes, and snippets.

@suntereichner
Last active April 1, 2020 12:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save suntereichner/6c2dd18e2f7cce3bb4540677f32bf384 to your computer and use it in GitHub Desktop.
Save suntereichner/6c2dd18e2f7cce3bb4540677f32bf384 to your computer and use it in GitHub Desktop.
package com.microfocus.uftd;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import com.hp.lft.report.ReportException;
import com.hp.lft.report.Reporter;
import com.hp.lft.sdk.GeneralLeanFtException;
import com.hp.lft.sdk.web.Browser;
import com.hp.lft.sdk.web.BrowserFactory;
import com.hp.lft.sdk.web.BrowserType;
import com.hp.lft.sdk.web.Button;
import com.hp.lft.sdk.web.ButtonDescription;
import com.hp.lft.sdk.web.EditField;
import com.hp.lft.sdk.web.EditFieldDescription;
import com.hp.lft.sdk.web.Link;
import com.hp.lft.sdk.web.LinkDescription;
import com.hp.lft.sdk.web.WebElement;
import com.hp.lft.sdk.web.WebElementDescription;
import com.hp.lft.verifications.Verify;
import unittesting.UnitTestClassBase;
public class LongRunningUITest extends UnitTestClassBase {
// adopt the number of repeats accordingly
private static final int REPEAT = 20;
public LongRunningUITest() {
// Change this constructor to private if you supply your own public constructor
}
@BeforeClass
public static void setUpBeforeClass() throws Exception {
instance = new LongRunningUITest();
globalSetup(LongRunningUITest.class);
}
@AfterClass
public static void tearDownAfterClass() throws Exception {
globalTearDown();
}
@Test
public void test() throws GeneralLeanFtException, ReportException {
Browser browser = BrowserFactory.launch(BrowserType.CHROME);
for (int i = 0; i < REPEAT; i++) {
long start = System.currentTimeMillis();
Reporter.startReportingContext("Run#" + i, "started");
browser.navigate("http://www.advantageonlineshopping.com/");
WebElement webElement = browser.describe(WebElement.class,
new WebElementDescription.Builder().id("menuSearch").build());
webElement.click();
EditField searchAdvantageOnlineShoppingComEditField = browser.describe(EditField.class,
new EditFieldDescription.Builder().name("WebEdit").tagName("INPUT").type("text").build());
searchAdvantageOnlineShoppingComEditField.setValue("Bose");
Link headphonesLink = browser.describe(Link.class,
new LinkDescription.Builder().innerText("headphones ").tagName("A").build());
headphonesLink.click();
WebElement boseSoundLinkAroundEarWirelessHeadphonesIIWebElement = browser.describe(WebElement.class,
new WebElementDescription.Builder().innerText("Bose SoundLink Around-ear Wireless Headphones II")
.tagName("A").build());
boseSoundLinkAroundEarWirelessHeadphonesIIWebElement.click();
Button saveToCartButton = browser.describe(Button.class,
new ButtonDescription.Builder().buttonType("submit").name("ADD TO CART").tagName("BUTTON").build());
Verify.areEqual("roboto-medium ng-scope disable", saveToCartButton.getClassName(), "Verification",
"Verify property: className");
Link dvantageDEMOLink = browser.describe(Link.class,
new LinkDescription.Builder().innerText("dvantage DEMO ").tagName("A").build());
dvantageDEMOLink.click();
long end = System.currentTimeMillis();
Reporter.reportEvent("Run#" + i+ " finished in " + (end-start) + " ms", "");
Reporter.endReportingContext();
}
browser.close();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment