Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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 SingleUITest extends UnitTestClassBase {
public SingleUITest() {
// Change this constructor to private if you supply your own public constructor
}
@BeforeClass
public static void setUpBeforeClass() throws Exception {
instance = new SingleUITest();
globalSetup(SingleUITest.class);
}
@AfterClass
public static void tearDownAfterClass() throws Exception {
globalTearDown();
}
@Test
public void test() throws GeneralLeanFtException, ReportException {
BrowserDescription browserDesc = new BrowserDescription.Builder().build();
browserDesc.set("type", BrowserType.FIREFOX);
browserDesc.set("profile_proxy", "http://localhost:8156");
Browser browser = BrowserFactory.launch(browserDesc);
long start = System.currentTimeMillis();
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("Test execution took " + (end - start) + " ms", "");
browser.close();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.