use of com.seleniumtests.connectors.selenium.fielddetector.Field in project seleniumRobot by bhecquet.
the class TestImageFieldDetector method testDetectFieldsWrongFormat.
@Test(groups = { "ut" })
public void testDetectFieldsWrongFormat() throws IOException {
JSONObject obj = new JSONObject("{" + " \"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);
List<Field> fields = new ImageFieldDetector(image).detectFields();
Assert.assertEquals(fields.size(), 0);
}
use of com.seleniumtests.connectors.selenium.fielddetector.Field in project seleniumRobot by bhecquet.
the class TestLabel method testIsInside.
/**
* With same coordinates, label is inside field
*/
@Test(groups = { "ut" })
public void testIsInside() {
Label label = Label.fromJson(new JSONObject("{" + " \"top\": 674," + " \"left\": 20," + " \"width\": 121," + " \"height\": 22," + " \"text\": \"My link Parent\"," + " \"right\": 141," + " \"bottom\": 696" + " }"));
Field field = Field.fromJson(new JSONObject("{" + " \"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" + " }"));
Assert.assertTrue(label.isInside(field));
Assert.assertFalse(label.isFieldLeftOf(field));
Assert.assertFalse(label.isFieldRightOf(field));
Assert.assertFalse(label.isFieldAbove(field));
Assert.assertFalse(label.isFieldBelow(field));
}
use of com.seleniumtests.connectors.selenium.fielddetector.Field in project seleniumRobot by bhecquet.
the class TestLabel method testIsNotInsideRight.
/**
* Label is on the right of field
* ----- ------
* Field Label
* ----- ------
*/
@Test(groups = { "ut" })
public void testIsNotInsideRight() {
Label label = Label.fromJson(new JSONObject("{" + " \"top\": 674," + " \"left\": 150," + " \"width\": 100," + " \"height\": 20," + " \"text\": \"My link Parent\"," + " \"right\": 250," + " \"bottom\": 694" + " }"));
Field field = Field.fromJson(new JSONObject("{" + " \"class_id\": 3," + " \"top\": 674," + " \"bottom\": 694," + " \"left\": 100," + " \"right\": 200," + " \"class_name\": \"radio_with_label\"," + " \"text\": \"= Value 4\"," + " \"related_field\": null," + " \"with_label\": true," + " \"width\": 100," + " \"height\": 20" + " }"));
Assert.assertFalse(label.isInside(field));
Assert.assertTrue(label.isFieldLeftOf(field));
Assert.assertFalse(label.isFieldRightOf(field));
Assert.assertFalse(label.isFieldAbove(field));
Assert.assertFalse(label.isFieldBelow(field));
}
use of com.seleniumtests.connectors.selenium.fielddetector.Field in project seleniumRobot by bhecquet.
the class TestLabel method testIsNotInsideBelow.
/**
* Label is on the bottom of field
* ------
* Field
* ------
*
* -----
* Label
* -----
*/
@Test(groups = { "ut" })
public void testIsNotInsideBelow() {
Label label = Label.fromJson(new JSONObject("{" + " \"top\": 684," + " \"left\": 20," + " \"width\": 121," + " \"height\": 22," + " \"text\": \"My link Parent\"," + " \"right\": 141," + " \"bottom\": 704" + " }"));
Field field = Field.fromJson(new JSONObject("{" + " \"class_id\": 3," + " \"top\": 674," + " \"bottom\": 694," + " \"left\": 20," + " \"right\": 141," + " \"class_name\": \"radio_with_label\"," + " \"text\": \"= Value 4\"," + " \"related_field\": null," + " \"with_label\": true," + " \"width\": 121," + " \"height\": 22" + " }"));
Assert.assertFalse(label.isInside(field));
Assert.assertFalse(label.isFieldLeftOf(field));
Assert.assertFalse(label.isFieldRightOf(field));
Assert.assertTrue(label.isFieldAbove(field));
Assert.assertFalse(label.isFieldBelow(field));
}
use of com.seleniumtests.connectors.selenium.fielddetector.Field in project seleniumRobot by bhecquet.
the class TestLabel method testFieldAndLabelNotAligned1.
/**
* Field on the left, but not aligned horizontally
*
* ------
* Field
* ------
*
* -----
* Label
* -----
*/
@Test(groups = { "ut" })
public void testFieldAndLabelNotAligned1() {
Label label = Label.fromJson(new JSONObject("{" + " \"top\": 200," + " \"left\": 100," + " \"width\": 100," + " \"height\": 20," + " \"right\": 200," + " \"bottom\": 220," + " \"text\": \"My link Parent\"" + " }"));
Field field = Field.fromJson(new JSONObject("{" + " \"class_id\": 3," + " \"top\": 100," + " \"left\": 200," + " \"width\": 100," + " \"height\": 20," + " \"right\": 300," + " \"bottom\": 120," + " \"class_name\": \"radio_with_label\"," + " \"text\": \"= Value 4\"," + " \"related_field\": null," + " \"with_label\": true" + " }"));
Assert.assertFalse(label.isInside(field));
Assert.assertFalse(label.isFieldLeftOf(field));
Assert.assertFalse(label.isFieldRightOf(field));
Assert.assertFalse(label.isFieldAbove(field));
Assert.assertFalse(label.isFieldBelow(field));
}
Aggregations