use of com.seleniumtests.uipage.htmlelements.ElementInfo in project seleniumRobot by bhecquet.
the class TestElementInfo method testUpdateInfoForAppTesting.
/**
* create element information simulating application testing. In this mode, some information are not available (those specific to web browsing): tagName and attributes
*/
@Test(groups = { "ut" })
public void testUpdateInfoForAppTesting() {
SeleniumTestsContextManager.getThreadContext().setTestType(TestType.APP);
ElementInfo elInfo = spy(ElementInfo.getInstance(htmlElement));
doReturn(image).when(elInfo).getScreenshot();
elInfo.updateInfo(htmlElement);
// check element info is created with basic information
Assert.assertNotNull(elInfo);
Assert.assertEquals(elInfo.getText(), "sometext");
Assert.assertEquals(elInfo.getCoordX(), (Integer) 10);
Assert.assertEquals(elInfo.getCoordY(), (Integer) 20);
Assert.assertEquals(elInfo.getHeight(), (Integer) 30);
Assert.assertEquals(elInfo.getWidth(), (Integer) 40);
Assert.assertEquals(elInfo.getTotalSearch(), 1);
// tagname not initialized for apps
Assert.assertEquals(elInfo.getTagName(), "");
// attributes not initalized for apps
Assert.assertEquals(elInfo.getAttributes().size(), 0);
Assert.assertEquals(elInfo.getB64Image(), "ABCD");
}
use of com.seleniumtests.uipage.htmlelements.ElementInfo in project seleniumRobot by bhecquet.
the class TestElementInfo method testCreateNewInfo.
/**
* Create a new elementInfo
*/
@Test(groups = { "ut" })
public void testCreateNewInfo() {
ElementInfo elInfo = ElementInfo.getInstance(htmlElement);
// check element info is created with basic information
Assert.assertNotNull(elInfo);
Assert.assertEquals(elInfo.getId(), "foo.bar.Page/mylabel");
Assert.assertEquals(elInfo.getName(), "mylabel");
Assert.assertEquals(elInfo.getLocator(), "By.id: foo");
Assert.assertNull(elInfo.getTagName());
Assert.assertNull(elInfo.getText());
Assert.assertEquals((Integer) 0, elInfo.getCoordX());
Assert.assertEquals((Integer) 0, elInfo.getCoordY());
Assert.assertEquals((Integer) 0, elInfo.getWidth());
Assert.assertEquals((Integer) 0, elInfo.getHeight());
Assert.assertEquals(elInfo.getTotalSearch(), 0);
}
use of com.seleniumtests.uipage.htmlelements.ElementInfo in project seleniumRobot by bhecquet.
the class TestElementInfo method testReadFromNonExistentJson.
/**
* Check we return null if the file information cannot be found
* @throws IOException
*/
@Test(groups = { "ut" })
public void testReadFromNonExistentJson() throws IOException {
ElementInfo elementInfo = ElementInfo.readFromJsonFile(new File("foo.json"));
Assert.assertNull(elementInfo);
}
use of com.seleniumtests.uipage.htmlelements.ElementInfo in project seleniumRobot by bhecquet.
the class TestElementInfo method testCreateNewInfoWithFalseMode.
/**
* Do not create new ElementInfo, do not even search as we forbid this
*/
@Test(groups = { "ut" })
public void testCreateNewInfoWithFalseMode() {
SeleniumTestsContextManager.getThreadContext().setAdvancedElementSearch("false");
ElementInfo elInfo = ElementInfo.getInstance(htmlElement);
// check element info is created with basic information
Assert.assertNull(elInfo);
}
use of com.seleniumtests.uipage.htmlelements.ElementInfo in project seleniumRobot by bhecquet.
the class TestElementInfo method testCreateElementInfoWithExistingInfo.
/**
* Test case where the ElementInfo already exists on disk
* We should get it
* @throws IOException
*/
@Test(groups = { "ut" })
public void testCreateElementInfoWithExistingInfo() throws IOException {
SeleniumTestsContextManager.getThreadContext().setTestType(TestType.WEB);
// write data to file we will then read
File elementInfoPath = ElementInfo.buildElementInfoPath(htmlElement);
FileUtils.write(elementInfoPath, JSON_INFO_FOO);
ElementInfo elInfo = spy(ElementInfo.getInstance(htmlElement));
// we should get the existing information
Assert.assertEquals(elInfo.getTagName(), "h1");
}
Aggregations