use of com.seleniumtests.connectors.selenium.fielddetector.Field in project seleniumRobot by bhecquet.
the class TestField method testMatches.
@Test(groups = { "ut" })
public void testMatches() {
Field f1 = new Field(0, 100, 0, 20, "foobar", "field");
Field f2 = new Field(0, 99, 0, 20, "fooba", "field");
Assert.assertTrue(f1.match(f2));
}
use of com.seleniumtests.connectors.selenium.fielddetector.Field in project seleniumRobot by bhecquet.
the class TestField method testChangePosition.
@Test(groups = { "ut" })
public void testChangePosition() {
Field field = Field.fromJson(new JSONObject("{" + " \"top\": 2261," + " \"left\": 8," + " \"width\": 96," + " \"height\": 14," + " \"class_name\": \"radio_with_label\"," + " \"class_id\": 3," + " \"text\": \"= Value 4\"," + " \"related_field\": null," + " \"with_label\": true," + " \"right\": 104," + " \"bottom\": 2275" + " }"));
field.changePosition(10, 20);
Assert.assertEquals(field.getLabel().getLeft(), 18);
Assert.assertEquals(field.getLabel().getRight(), 114);
Assert.assertEquals(field.getLabel().getTop(), 2281);
Assert.assertEquals(field.getLabel().getBottom(), 2295);
Assert.assertEquals(field.getLabel().getHeight(), 14);
Assert.assertEquals(field.getLabel().getWidth(), 96);
}
use of com.seleniumtests.connectors.selenium.fielddetector.Field in project seleniumRobot by bhecquet.
the class TestField method testNoMatchePosition.
@Test(groups = { "ut" })
public void testNoMatchePosition() {
Field f1 = new Field(0, 100, 0, 20, "foobar", "field");
Field f2 = new Field(100, 199, 0, 20, "fooba", "field");
Assert.assertFalse(f1.match(f2));
}
use of com.seleniumtests.connectors.selenium.fielddetector.Field in project seleniumRobot by bhecquet.
the class TestField method testFromJsonRelatedField.
@Test(groups = { "ut" })
public void testFromJsonRelatedField() {
Field field = Field.fromJson(new JSONObject("{" + " \"class_id\": 4," + " \"top\": 203," + " \"bottom\": 225," + " \"left\": 21," + " \"right\": 351," + " \"class_name\": \"field_with_label\"," + " \"text\": \"Pr\\u00e9nom\"," + " \"related_field\": {" + " \"class_id\": 0," + " \"top\": 205," + " \"bottom\": 224," + " \"left\": 76," + " \"right\": 354," + " \"class_name\": \"field\"," + " \"text\": null," + " \"related_field\": null," + " \"with_label\": false," + " \"width\": 278," + " \"height\": 19" + " }," + " \"with_label\": true," + " \"width\": 330," + " \"height\": 22" + " }"));
Assert.assertEquals(field.getInnerFieldRectangle(), new Rectangle(76, 205, 278, 19));
}
use of com.seleniumtests.connectors.selenium.fielddetector.Field in project seleniumRobot by bhecquet.
the class TestImageFieldDetector method testDetectFieldsAndLabels.
/**
* Check detector is called only once event if we detect fields and labeld
* @throws IOException
*/
@Test(groups = { "ut" })
public void testDetectFieldsAndLabels() 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" + " }]," + " \"labels\": [{" + " \"top\": 24," + " \"left\": 8," + " \"width\": 244," + " \"height\": 16," + " \"text\": \"Test clicking a moving element\"," + " \"right\": 252," + " \"bottom\": 40" + " }," + " {" + " \"top\": 63," + " \"left\": 16," + " \"width\": 89," + " \"height\": 11," + " \"text\": \"Start Animation\"," + " \"right\": 105," + " \"bottom\": 74" + " }]" + "} ");
File image = createImageFromResource("ti/form_picture.png");
when(fieldDetectorConnector.detect(image, 1)).thenReturn(obj);
SeleniumTestsContextManager.getGlobalContext().setFieldDetectorInstance(fieldDetectorConnector);
ImageFieldDetector detector = new ImageFieldDetector(image);
List<Field> fields = detector.detectFields();
List<Label> labels = detector.detectLabels();
// detector is called only once
verify(fieldDetectorConnector).detect(image, 1);
}
Aggregations