Search in sources :

Example 36 with Label

use of com.seleniumtests.connectors.selenium.fielddetector.Label in project seleniumRobot by bhecquet.

the class TestUiElement method init.

@BeforeMethod(groups = { "ut" })
public void init() {
    UiElement.resetPageInformation();
    /*
		 * Create fields and labels
		 * 
		 * 								field4
		 * 
		 * 								label1Below
		 * 
		 *	field5		label1Right		field1/labelInside		label1Left		field3
		 * 
		 * 								label1Above
		 * 
		 * 								field2
		 * 
		 */
    // field to the left of "label1Left" and to the right of "label1Right"
    field1 = new Field(200, 300, 100, 120, null, "field");
    fieldWithLabel = new Field(100, 300, 100, 120, null, "field_with_label", field1);
    // field above "label1Above"
    field2 = new Field(200, 300, 300, 320, null, "field");
    // field to the right of "label1Left"
    field3 = new Field(600, 700, 100, 120, null, "field");
    // field above "label1Below"
    field4 = new Field(200, 300, 0, 20, null, "field");
    // field to the left of "label1Right"
    field5 = new Field(10, 60, 100, 120, null, "field");
    label1Right = new Label(100, 150, 100, 120, "label_with_field_on_right");
    label1Left = new Label(350, 400, 100, 120, "label_with_field_on_left");
    // label longer than field
    label1Above = new Label(200, 400, 200, 220, "label_with_field_above");
    // label shorter than field
    label1Below = new Label(200, 252, 70, 90, "label_with_field_below");
    label2 = new Label(100, 150, 0, 20, "label_without_field");
    labelInside = new Label(200, 250, 100, 120, "label_inside");
    PowerMockito.mockStatic(CustomEventFiringWebDriver.class);
    PowerMockito.mockStatic(WebUIDriver.class);
    PowerMockito.when(WebUIDriver.getWebDriver(anyBoolean())).thenReturn(driver);
    when(driver.getBrowserInfo()).thenReturn(new BrowserInfo(BrowserType.CHROME, "83.0"));
}
Also used : Field(com.seleniumtests.connectors.selenium.fielddetector.Field) BrowserInfo(com.seleniumtests.browserfactory.BrowserInfo) Label(com.seleniumtests.connectors.selenium.fielddetector.Label) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 37 with Label

use of com.seleniumtests.connectors.selenium.fielddetector.Label in project seleniumRobot by bhecquet.

the class TestStepReferenceComparator method testCompareNoField.

@Test(groups = { "ut" })
public void testCompareNoField() throws Exception {
    List<Label> stepLabels = new ArrayList<>();
    stepLabels.add(new Label(0, 100, 0, 20, "a text"));
    stepLabels.add(new Label(0, 100, 100, 120, "other text"));
    List<Label> referenceLabels = new ArrayList<>();
    referenceLabels.add(new Label(0, 100, 0, 20, "a text"));
    referenceLabels.add(new Label(5, 105, 100, 120, "other text"));
    PowerMockito.whenNew(ImageFieldDetector.class).withAnyArguments().thenReturn(stepImageFieldDetector, refImageFieldDetector);
    when(stepImageFieldDetector.detectLabels()).thenReturn(stepLabels);
    when(refImageFieldDetector.detectLabels()).thenReturn(referenceLabels);
    StepReferenceComparator comparator = new StepReferenceComparator(File.createTempFile("img", ".png"), File.createTempFile("img", ".png"));
    Assert.assertEquals(comparator.compare(), 100);
}
Also used : Label(com.seleniumtests.connectors.selenium.fielddetector.Label) ArrayList(java.util.ArrayList) StepReferenceComparator(com.seleniumtests.util.imaging.StepReferenceComparator) Test(org.testng.annotations.Test) MockitoTest(com.seleniumtests.MockitoTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Aggregations

Label (com.seleniumtests.connectors.selenium.fielddetector.Label)37 Test (org.testng.annotations.Test)31 GenericTest (com.seleniumtests.GenericTest)26 Field (com.seleniumtests.connectors.selenium.fielddetector.Field)22 File (java.io.File)14 MockitoTest (com.seleniumtests.MockitoTest)13 JSONObject (kong.unirest.json.JSONObject)13 ArrayList (java.util.ArrayList)11 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)10 ErrorCause (com.seleniumtests.core.testanalysis.ErrorCause)8 ErrorCauseFinder (com.seleniumtests.core.testanalysis.ErrorCauseFinder)8 ITestResult (org.testng.ITestResult)8 ImageFieldDetector (com.seleniumtests.connectors.selenium.fielddetector.ImageFieldDetector)6 ConfigurationException (com.seleniumtests.customexception.ConfigurationException)4 SeleniumRobotServerException (com.seleniumtests.customexception.SeleniumRobotServerException)2 Snapshot (com.seleniumtests.reporter.logger.Snapshot)2 TestStep (com.seleniumtests.reporter.logger.TestStep)2 StepReferenceComparator (com.seleniumtests.util.imaging.StepReferenceComparator)2 Rectangle (java.awt.Rectangle)2 BrowserInfo (com.seleniumtests.browserfactory.BrowserInfo)1