use of org.utils.ShareDataTest.Element in project selenium_java by sergueik.
the class ShareDataTest method beforeMethod.
@BeforeMethod
public void beforeMethod(Method method, ITestResult testresult) {
// alternative: ITestContext context
// super.beforeMethod(method, testresult);
Inject inject = method.getAnnotation(Inject.class);
if (inject != null) {
Element data = new Element("//", 1);
testresult.setAttribute("element", data);
}
}
use of org.utils.ShareDataTest.Element in project selenium_java by sergueik.
the class ShareDataTest method dataConsumingTest.
@Test
@Inject
public void dataConsumingTest() {
ITestResult testresult = Reporter.getCurrentTestResult();
Object data = testresult.getAttribute("element");
if (data instanceof Element) {
Assert.assertNotNull(((Element) data).getName(), "Data element must provide the name");
Assert.assertTrue(((Element) data).getCount() != 0, "Data element must provide nonzero count");
}
}
Aggregations