Hi,
I am using testNG framework. I am having Base class and other classes CreateClient, CreateProject, CreateUser, AccessToProjects extends base.
Steps to reproduce :
1. Create client class creates new client that us random name and saved in iTestContext object passed in @Test method.
2. Create project class creates new project for client(select from dropdown) that is created in created client class by using getProperty method of iTestContext object.
3 Create user creates new user for client created using getProperty method of iTestContext object.
Everything working fine here.
4. AccessToProject class give access to user for particular project. For this i need to select user that is created in CreatedUser class. I am doing same way by iTestContext object.
On user page, there are many users that are in <li>/<a> tag inside <ul> tag.
So i am equating if option in list equals to user name created then click it.
@Test
public void project_access(ITestContext itc) {
usercreated = (String) itc.getAttribute(CreateUser.user_name); /* pull user name from CreateUser class */
System.out.println("new user created : " +usercreated);
/* pull all elements in list >
List<WebElement> li =
driver.findElements(By.xpath(".//*[@id='users-list']/ul/li/div/div/div[1]/span/a"));
for(WebElement userlist : li) {
if (userlist.getText().equals(usercreated)) {
userlist.click();
return;
}
}
Now there are 2 scenarios :
1. I run my suite commenting @After Test method that closes browser that is defined in Base class. It gives me error Can inject only one of <ITestContext, XmlTest> into a AfterTest annotated click.
I dont have any clue regarding this.
2 I run mu suite without commenting @AfterSuite method, it doe snot give any error. But it does not go inside for loop. I put SOP statement after List<> line, its getting printed. But its not going inside loop.
Thanks,
Garvita Girotra