Search in sources :

Example 11 with Label

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

the class TestImageFieldDetector method testDetectLabelsWrongFormat.

@Test(groups = { "ut" })
public void testDetectLabelsWrongFormat() throws IOException {
    JSONObject obj = new JSONObject("{" + "	\"fields\": [{" + "		\"class_id\": 3," + "		\"top\": 674," + "		\"bottom\": 696," + "		\"left\": 20," + "		\"right\": 141," + "		\"class_name\": \"radio_with_label\"," + "		\"text\": \"= Value 4\"," + "		\"related_field\": null," + "		\"with_label\": true," + "		\"width\": 121," + "		\"height\": 22" + "	}," + "	{" + "		\"class_id\": 3," + "		\"top\": 975," + "		\"bottom\": 996," + "		\"left\": 4," + "		\"right\": 90," + "		\"class_name\": \"radio_with_label\"," + "		\"text\": \"an other text\"," + "		\"related_field\": null," + "		\"with_label\": true," + "		\"width\": 86," + "		\"height\": 21" + "	}]" + "} ");
    File image = createImageFromResource("ti/form_picture.png");
    when(fieldDetectorConnector.detect(image, 2)).thenReturn(obj);
    SeleniumTestsContextManager.getGlobalContext().setFieldDetectorInstance(fieldDetectorConnector);
    List<Label> labels = new ImageFieldDetector(image, 2).detectLabels();
    Assert.assertEquals(labels.size(), 0);
}
Also used : JSONObject(kong.unirest.json.JSONObject) ImageFieldDetector(com.seleniumtests.connectors.selenium.fielddetector.ImageFieldDetector) Label(com.seleniumtests.connectors.selenium.fielddetector.Label) File(java.io.File) Test(org.testng.annotations.Test) MockitoTest(com.seleniumtests.MockitoTest)

Example 12 with Label

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

the class TestLabel method testFromJson.

@Test(groups = { "ut" })
public void testFromJson() {
    Label label = Label.fromJson(new JSONObject("{" + "		\"top\": 2261," + "		\"left\": 8," + "		\"width\": 96," + "		\"height\": 14," + "		\"text\": \"My link Parent\"," + "		\"right\": 104," + "		\"bottom\": 2275" + "	}"));
    Assert.assertEquals(label.getLeft(), 8);
    Assert.assertEquals(label.getRight(), 104);
    Assert.assertEquals(label.getTop(), 2261);
    Assert.assertEquals(label.getBottom(), 2275);
    Assert.assertEquals(label.getHeight(), 14);
    Assert.assertEquals(label.getWidth(), 96);
    Assert.assertEquals(label.getText(), "My link Parent");
}
Also used : JSONObject(kong.unirest.json.JSONObject) Label(com.seleniumtests.connectors.selenium.fielddetector.Label) Test(org.testng.annotations.Test) GenericTest(com.seleniumtests.GenericTest)

Example 13 with Label

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

the class TestLabel method testMatchesNullText2.

@Test(groups = { "ut" })
public void testMatchesNullText2() {
    Label l1 = new Label(0, 100, 0, 20, "foobar");
    Label l2 = new Label(0, 99, 0, 20, null);
    Assert.assertFalse(l1.match(l2));
}
Also used : Label(com.seleniumtests.connectors.selenium.fielddetector.Label) Test(org.testng.annotations.Test) GenericTest(com.seleniumtests.GenericTest)

Example 14 with Label

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

the class TestLabel method testChangePosition.

@Test(groups = { "ut" })
public void testChangePosition() {
    Label label = Label.fromJson(new JSONObject("{" + "		\"top\": 2261," + "		\"left\": 8," + "		\"width\": 96," + "		\"height\": 14," + "		\"text\": \"My link Parent\"," + "		\"right\": 104," + "		\"bottom\": 2275" + "	}"));
    label.changePosition(10, 20);
    Assert.assertEquals(label.getLeft(), 18);
    Assert.assertEquals(label.getRight(), 114);
    Assert.assertEquals(label.getTop(), 2281);
    Assert.assertEquals(label.getBottom(), 2295);
    Assert.assertEquals(label.getHeight(), 14);
    Assert.assertEquals(label.getWidth(), 96);
}
Also used : JSONObject(kong.unirest.json.JSONObject) Label(com.seleniumtests.connectors.selenium.fielddetector.Label) Test(org.testng.annotations.Test) GenericTest(com.seleniumtests.GenericTest)

Example 15 with Label

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

the class TestLabel method testMatchesNullText.

@Test(groups = { "ut" })
public void testMatchesNullText() {
    Label l1 = new Label(0, 100, 0, 20, null);
    Label l2 = new Label(0, 99, 0, 20, "fooba");
    Assert.assertFalse(l1.match(l2));
}
Also used : Label(com.seleniumtests.connectors.selenium.fielddetector.Label) Test(org.testng.annotations.Test) GenericTest(com.seleniumtests.GenericTest)

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