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);
}
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");
}
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));
}
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);
}
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));
}
Aggregations