Getting this error : Can inject only one of <ITestContext, XmlTest> into a AfterTest annotated click.

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Getting this error : Can inject only one of <ITestContext, XmlTest> into a AfterTest annotated click.

garvitagirotraev
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

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Getting this error : Can inject only one of <ITestContext, XmlTest> into a AfterTest annotated click.

Krishnan Mahadevan
Can you please help share a simple standalone example which we can execute to reproduce the problem ? That way its easy for us to visualise/see what is the problem as well.


Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/
My Technical Scribbings @ http://rationaleemotions.wordpress.com/

On Thu, Jun 22, 2017 at 11:01 AM, <[hidden email]> wrote:
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

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Getting this error : Can inject only one of <ITestContext, XmlTest> into a AfterTest annotated click.

garvitagirotraev
Hi Krishan,

I am running my suite on headless browser on local server. There is no global link for application that i can provide for sample run.

Thanks, 
Garvita Girotra

On Thursday, June 22, 2017 at 12:36:12 PM UTC+5:30, Krishnan wrote:
Can you please help share a simple standalone example which we can execute to reproduce the problem ? That way its easy for us to visualise/see what is the problem as well.


Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ <a href="http://wakened-cognition.blogspot.com/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwakened-cognition.blogspot.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHzOdYJCASIDF_28vQtkp9gnKAYSQ&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwakened-cognition.blogspot.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHzOdYJCASIDF_28vQtkp9gnKAYSQ&#39;;return true;">http://wakened-cognition.blogspot.com/
My Technical Scribbings @ <a href="http://rationaleemotions.wordpress.com/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Frationaleemotions.wordpress.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEcBOKyRn0lpL8LDbBuyAlKdwgXwQ&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Frationaleemotions.wordpress.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEcBOKyRn0lpL8LDbBuyAlKdwgXwQ&#39;;return true;">http://rationaleemotions.wordpress.com/

On Thu, Jun 22, 2017 at 11:01 AM, <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="UWxvmsUaBAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">garvitag...@...> wrote:
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

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="UWxvmsUaBAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">testng-users...@googlegroups.com.
To post to this group, send email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="UWxvmsUaBAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">testng...@....
Visit this group at <a href="https://groups.google.com/group/testng-users" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/group/testng-users&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/group/testng-users&#39;;return true;">https://groups.google.com/group/testng-users.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Getting this error : Can inject only one of <ITestContext, XmlTest> into a AfterTest annotated click.

Krishnan Mahadevan
Why not create a simple standalone test which doesnt use any of the UI stuff and share that with us, so that we can use that to reproduce your problem ?

Without a reproducible test, its hard to take a jab at your issue and tell you what might be wrong.

Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/
My Technical Scribbings @ http://rationaleemotions.wordpress.com/

On Wed, Jun 28, 2017 at 12:27 PM, <[hidden email]> wrote:
Hi Krishan,

I am running my suite on headless browser on local server. There is no global link for application that i can provide for sample run.

Thanks, 
Garvita Girotra

On Thursday, June 22, 2017 at 12:36:12 PM UTC+5:30, Krishnan wrote:
Can you please help share a simple standalone example which we can execute to reproduce the problem ? That way its easy for us to visualise/see what is the problem as well.


Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/
My Technical Scribbings @ http://rationaleemotions.wordpress.com/

On Thu, Jun 22, 2017 at 11:01 AM, <[hidden email]> wrote:
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

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to testng-users...@googlegroups.com.
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
Loading...