Search in sources :

Example 16 with Field

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);
}
Also used : Field(com.seleniumtests.connectors.selenium.fielddetector.Field) JSONObject(kong.unirest.json.JSONObject) ImageFieldDetector(com.seleniumtests.connectors.selenium.fielddetector.ImageFieldDetector) File(java.io.File) Test(org.testng.annotations.Test) MockitoTest(com.seleniumtests.MockitoTest)

Example 17 with Field

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));
}
Also used : Field(com.seleniumtests.connectors.selenium.fielddetector.Field) JSONObject(kong.unirest.json.JSONObject) Label(com.seleniumtests.connectors.selenium.fielddetector.Label) Test(org.testng.annotations.Test) GenericTest(com.seleniumtests.GenericTest)

Example 18 with 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));
}
Also used : Field(com.seleniumtests.connectors.selenium.fielddetector.Field) JSONObject(kong.unirest.json.JSONObject) Label(com.seleniumtests.connectors.selenium.fielddetector.Label) Test(org.testng.annotations.Test) GenericTest(com.seleniumtests.GenericTest)

Example 19 with 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));
}
Also used : Field(com.seleniumtests.connectors.selenium.fielddetector.Field) JSONObject(kong.unirest.json.JSONObject) Label(com.seleniumtests.connectors.selenium.fielddetector.Label) Test(org.testng.annotations.Test) GenericTest(com.seleniumtests.GenericTest)

Example 20 with 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));
}
Also used : Field(com.seleniumtests.connectors.selenium.fielddetector.Field) JSONObject(kong.unirest.json.JSONObject) Label(com.seleniumtests.connectors.selenium.fielddetector.Label) Test(org.testng.annotations.Test) GenericTest(com.seleniumtests.GenericTest)

Aggregations

Field (com.seleniumtests.connectors.selenium.fielddetector.Field)35 Test (org.testng.annotations.Test)29 GenericTest (com.seleniumtests.GenericTest)23 Label (com.seleniumtests.connectors.selenium.fielddetector.Label)22 File (java.io.File)17 MockitoTest (com.seleniumtests.MockitoTest)14 JSONObject (kong.unirest.json.JSONObject)14 ArrayList (java.util.ArrayList)11 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)10 ImageFieldDetector (com.seleniumtests.connectors.selenium.fielddetector.ImageFieldDetector)9 ErrorCause (com.seleniumtests.core.testanalysis.ErrorCause)8 ErrorCauseFinder (com.seleniumtests.core.testanalysis.ErrorCauseFinder)8 ITestResult (org.testng.ITestResult)8 ConfigurationException (com.seleniumtests.customexception.ConfigurationException)5 Rectangle (java.awt.Rectangle)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 BrowserInfo (com.seleniumtests.browserfactory.BrowserInfo)1