webdriver + testng

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

webdriver + testng

Rafael Carvalho
Hi friends,

I have the following script of the example:

package MenuAtNeed;

import org.testng.annotations.AfterMethod;
import org.testng.annotations.Test;
import org.testng.annotations.BeforeMethod;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.*;
import org.openqa.selenium.firefox.FirefoxDriver;

  public class Google {
    private WebDriver driver;
    private String baseUrl;
  
  @BeforeMethod
  public void setUp() throws Exception {
    driver = new FirefoxDriver();
    baseUrl = "http://google.com.br";
    driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
  }

  @Test 
  public void foundGoogle() throws Exception {
    driver.get(baseUrl);
    driver.manage().window().maximize();
    driver.findElement(By.id("gs_tti0")).sendKeys("dfteste");
    driver.findElement(By.id("gbqfba")).click();
    
  }
  
  @Test
  public void clickInTheResult() throws Exception {    
    driver.findElement(By.xpath("//*[@href='http://br.dir.groups.yahoo.com/group/DFTestes/']")).click();

  }
  

 @AfterMethod
    public void tearDown() throws Exception {
    driver.quit();
    }
}

-------------------------------------------------------------

I have only one class with two methods, but, when the script running and execute the method public void clickInTheResult, a new window opens.

how can I run both methods with just one call declared driver.get?

--
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 http://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: webdriver + testng

niharika varshney
After you changed it to before and afterclass, what's the error you get?

Regards,
Niharika

On Wednesday, January 8, 2014, raf das wrote:
Hi friends,

I have the following script of the example:

package MenuAtNeed;

import org.testng.annotations.AfterMethod;
import org.testng.annotations.Test;
import org.testng.annotations.BeforeMethod;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.*;
import org.openqa.selenium.firefox.FirefoxDriver;

  public class Google {
    private WebDriver driver;
    private String baseUrl;
  
  @BeforeMethod
  public void setUp() throws Exception {
    driver = new FirefoxDriver();
    baseUrl = "http://google.com.br";
    driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
  }

  @Test 
  public void foundGoogle() throws Exception {
    driver.get(baseUrl);
    driver.manage().window().maximize();
    driver.findElement(By.id("gs_tti0")).sendKeys("dfteste");
    driver.findElement(By.id("gbqfba")).click();
    
  }
  
  @Test
  public void clickInTheResult() throws Exception {    
    driver.findElement(By.xpath("//*[@href='http://br.dir.groups.yahoo.com/group/DFTestes/']")).click();

  }
  

 @AfterMethod
    public void tearDown() throws Exception {
    driver.quit();
    }
}

-------------------------------------------------------------

I have only one class with two methods, but, when the script running and execute the method public void clickInTheResult, a new window opens.

how can I run both methods with just one call declared driver.get?

--
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:_e({}, &#39;cvml&#39;, &#39;testng-users%2Bunsubscribe@googlegroups.com&#39;);" target="_blank">testng-users+unsubscribe@....
To post to this group, send email to <a href="javascript:_e({}, &#39;cvml&#39;, &#39;testng-users@googlegroups.com&#39;);" target="_blank">testng-users@....
Visit this group at http://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/groups/opt_out.

--
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 http://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: webdriver + testng

Rafael Carvalho
Friend,

Execute only first method and appears error:

[TestNG] Running:
  C:\Users\Rafael\AppData\Local\Temp\testng-eclipse--106282693\testng-customsuite.xml

PASSED: clicaNoResultado
FAILED: PesquisaNoGoogle
org.openqa.selenium.ElementNotVisibleException: Element is not currently visible and so may not be interacted with
Command duration or timeout: 30.08 seconds
Build info: version: '2.37.0', revision: 'a7c61cb', time: '2013-10-18 17:15:02'
System info: host: 'Rafael-PC', ip: '192.168.139.1', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.7.0_17'
Session ID: e6ae8c3e-e9e1-41c7-bc76-3ccb6d476b71
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities [{platform=XP, databaseEnabled=true, cssSelectorsEnabled=true, javascriptEnabled=true, acceptSslCerts=true, handlesAlerts=true, browserName=firefox, browserConnectionEnabled=true, nativeEvents=true, webStorageEnabled=true, rotatable=false, locationContextEnabled=true, applicationCacheEnabled=true, takesScreenshot=true, version=26.0}]
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:193)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:145)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:554)
at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:268)
at org.openqa.selenium.remote.RemoteWebElement.click(RemoteWebElement.java:79)
at MenuAtNeed.Google.PesquisaNoGoogle(Google.java:26)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:714)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
at org.testng.TestRunner.privateRun(TestRunner.java:767)
at org.testng.TestRunner.run(TestRunner.java:617)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:334)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)
at org.testng.SuiteRunner.run(SuiteRunner.java:240)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1224)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1149)
at org.testng.TestNG.run(TestNG.java:1057)
at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:111)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:204)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:175)
Caused by: org.openqa.selenium.remote.ErrorHandler$UnknownServerException: Element is not currently visible and so may not be interacted with
Build info: version: '2.37.0', revision: 'a7c61cb', time: '2013-10-18 17:15:02'
System info: host: 'Rafael-PC', ip: '192.168.139.1', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.7.0_17'
Driver info: driver.version: unknown
at <anonymous class>.fxdriver.preconditions.visible(file:///C:/Users/Rafael/AppData/Local/Temp/anonymous4645185270689254893webdriver-profile/extensions/[hidden email]/components/command_processor.js:8210)
at <anonymous class>.DelayedCommand.prototype.checkPreconditions_(file:///C:/Users/Rafael/AppData/Local/Temp/anonymous4645185270689254893webdriver-profile/extensions/[hidden email]/components/command_processor.js:10827)
at <anonymous class>.DelayedCommand.prototype.executeInternal_/h(file:///C:/Users/Rafael/AppData/Local/Temp/anonymous4645185270689254893webdriver-profile/extensions/[hidden email]/components/command_processor.js:10844)
at <anonymous class>.fxdriver.Timer.prototype.setTimeout/<.notify(file:///C:/Users/Rafael/AppData/Local/Temp/anonymous4645185270689254893webdriver-profile/extensions/[hidden email]/components/command_processor.js:396)


===============================================
    Default test
    Tests run: 2, Failures: 1, Skips: 0
===============================================


===============================================
Default suite
Total tests run: 2, Failures: 1, Skips: 0
===============================================

[TestNG] Time taken by org.testng.reporters.EmailableReporter2@10d32baa: 10 ms
[TestNG] Time taken by org.testng.reporters.JUnitReportReporter@3101e0a7: 9 ms
[TestNG] Time taken by org.testng.reporters.jq.Main@63435263: 35 ms
[TestNG] Time taken by org.testng.reporters.SuiteHTMLReporter@7aed9585: 36 ms
[TestNG] Time taken by org.testng.reporters.XMLReporter@28bf3bbb: 9 ms
[TestNG] Time taken by [FailedReporter passed=0 failed=0 skipped=0]: 5 ms


Em quarta-feira, 8 de janeiro de 2014 15h50min33s UTC-2, Niharika_Neo escreveu:
After you changed it to before and afterclass, what's the error you get?

Regards,
Niharika

On Wednesday, January 8, 2014, raf das wrote:
Hi friends,

I have the following script of the example:

package MenuAtNeed;

import org.testng.annotations.AfterMethod;
import org.testng.annotations.Test;
import org.testng.annotations.BeforeMethod;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.*;
import org.openqa.selenium.firefox.FirefoxDriver;

  public class Google {
    private WebDriver driver;
    private String baseUrl;
  
  @BeforeMethod
  public void setUp() throws Exception {
    driver = new FirefoxDriver();
    baseUrl = "<a href="http://google.com.br/" target="_blank" onmousedown="this.href='http://google.com.br/';return true;" onclick="this.href='http://google.com.br/';return true;">http://google.com.br";
    driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
  }

  @Test 
  public void foundGoogle() throws Exception {
    driver.get(baseUrl);
    driver.manage().window().maximize();
    driver.findElement(By.id("gs_tti0")).sendKeys("dfteste");
    driver.findElement(By.id("gbqfba")).click();
    
  }
  
  @Test
  public void clickInTheResult() throws Exception {    
    driver.findElement(By.xpath("//*[@href='<a href="http://br.dir.groups.yahoo.com/group/DFTestes/'" target="_blank" onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Fbr.dir.groups.yahoo.com%2Fgroup%2FDFTestes%2F\47\46sa\75D\46sntz\0751\46usg\75AFQjCNF06Nk1tRSdjZo4emzIOpURREhgAQ';return true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Fbr.dir.groups.yahoo.com%2Fgroup%2FDFTestes%2F\47\46sa\75D\46sntz\0751\46usg\75AFQjCNF06Nk1tRSdjZo4emzIOpURREhgAQ';return true;">http://br.dir.groups.yahoo.com/group/DFTestes/']")).click();

  }
  

 @AfterMethod
    public void tearDown() throws Exception {
    driver.quit();
    }
}

-------------------------------------------------------------

I have only one class with two methods, but, when the script running and execute the method public void clickInTheResult, a new window opens.

how can I run both methods with just one call declared driver.get?

--
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+unsubscribe@googlegroups.com.
To post to this group, send email to [hidden email].
Visit this group at <a href="http://groups.google.com/group/testng-users" target="_blank" onmousedown="this.href='http://groups.google.com/group/testng-users';return true;" onclick="this.href='http://groups.google.com/group/testng-users';return true;">http://groups.google.com/group/testng-users.
For more options, visit <a href="https://groups.google.com/groups/opt_out" target="_blank" onmousedown="this.href='https://groups.google.com/groups/opt_out';return true;" onclick="this.href='https://groups.google.com/groups/opt_out';return true;">https://groups.google.com/groups/opt_out.

--
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 http://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: webdriver + testng

Rafael Carvalho
In reply to this post by niharika varshney
after changing the code looked like this:

package MenuAtNeed;

import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.*;
import org.openqa.selenium.firefox.FirefoxDriver;

  public class Google {
private WebDriver driver;
    private String baseUrl;
  
  @BeforeClass
  public void setUp() throws Exception {
    driver = new FirefoxDriver();
    baseUrl = "http://google.com.br";
    driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
  }

  @Test 
  public void PesquisaNoGoogle() throws Exception {
    driver.get(baseUrl);
    driver.manage().window().maximize();
    driver.findElement(By.id("gbqfq")).sendKeys("dfteste");
    driver.findElement(By.id("gbqfba")).click();
    
  }
  
  @Test
  public void clicaNoResultado() throws Exception {    
driver.findElement(By.xpath("//*[@href='http://br.dir.groups.yahoo.com/group/DFTestes/']")).click();

  }
  

@AfterClass
public void tearDown() throws Exception {
    driver.quit();
    }
}

the test runs only the first method public void PesquisaNoGoogle() , but appears error:

[TestNG] Running:
  C:\Users\Rafael\AppData\Local\Temp\testng-eclipse-1801566236\testng-customsuite.xml

PASSED: clicaNoResultado
FAILED: PesquisaNoGoogle
org.openqa.selenium.ElementNotVisibleException: Element is not currently visible and so may not be interacted with
Command duration or timeout: 30.11 seconds
Build info: version: '2.37.0', revision: 'a7c61cb', time: '2013-10-18 17:15:02'
System info: host: 'Rafael-PC', ip: '192.168.139.1', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.7.0_17'
Session ID: 6961e54d-0007-477f-898a-639dc80d7f13
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities [{platform=XP, databaseEnabled=true, cssSelectorsEnabled=true, javascriptEnabled=true, acceptSslCerts=true, handlesAlerts=true, browserName=firefox, browserConnectionEnabled=true, nativeEvents=true, webStorageEnabled=true, rotatable=false, locationContextEnabled=true, applicationCacheEnabled=true, takesScreenshot=true, version=26.0}]
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:193)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:145)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:554)
at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:268)
at org.openqa.selenium.remote.RemoteWebElement.click(RemoteWebElement.java:79)
at MenuAtNeed.Google.PesquisaNoGoogle(Google.java:26)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:714)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
at org.testng.TestRunner.privateRun(TestRunner.java:767)
at org.testng.TestRunner.run(TestRunner.java:617)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:334)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)
at org.testng.SuiteRunner.run(SuiteRunner.java:240)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1224)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1149)
at org.testng.TestNG.run(TestNG.java:1057)
at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:111)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:204)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:175)
Caused by: org.openqa.selenium.remote.ErrorHandler$UnknownServerException: Element is not currently visible and so may not be interacted with
Build info: version: '2.37.0', revision: 'a7c61cb', time: '2013-10-18 17:15:02'
System info: host: 'Rafael-PC', ip: '192.168.139.1', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.7.0_17'
Driver info: driver.version: unknown
at <anonymous class>.fxdriver.preconditions.visible(file:///C:/Users/Rafael/AppData/Local/Temp/anonymous5139849955903958169webdriver-profile/extensions/[hidden email]/components/command_processor.js:8210)
at <anonymous class>.DelayedCommand.prototype.checkPreconditions_(file:///C:/Users/Rafael/AppData/Local/Temp/anonymous5139849955903958169webdriver-profile/extensions/[hidden email]/components/command_processor.js:10827)
at <anonymous class>.DelayedCommand.prototype.executeInternal_/h(file:///C:/Users/Rafael/AppData/Local/Temp/anonymous5139849955903958169webdriver-profile/extensions/[hidden email]/components/command_processor.js:10844)
at <anonymous class>.fxdriver.Timer.prototype.setTimeout/<.notify(file:///C:/Users/Rafael/AppData/Local/Temp/anonymous5139849955903958169webdriver-profile/extensions/[hidden email]/components/command_processor.js:396)


===============================================
    Default test
    Tests run: 2, Failures: 1, Skips: 0
===============================================


===============================================
Default suite
Total tests run: 2, Failures: 1, Skips: 0
===============================================

[TestNG] Time taken by org.testng.reporters.jq.Main@58d6147e: 38 ms
[TestNG] Time taken by org.testng.reporters.XMLReporter@22ea86e3: 13 ms
[TestNG] Time taken by [FailedReporter passed=0 failed=0 skipped=0]: 6 ms
[TestNG] Time taken by org.testng.reporters.JUnitReportReporter@72440d13: 8 ms
[TestNG] Time taken by org.testng.reporters.EmailableReporter2@17d7ae87: 5 ms
[TestNG] Time taken by org.testng.reporters.SuiteHTMLReporter@3f38dd0: 34 ms


Em quarta-feira, 8 de janeiro de 2014 15h50min33s UTC-2, Niharika_Neo escreveu:
After you changed it to before and afterclass, what's the error you get?

Regards,
Niharika

On Wednesday, January 8, 2014, raf das wrote:
Hi friends,

I have the following script of the example:

package MenuAtNeed;

import org.testng.annotations.AfterMethod;
import org.testng.annotations.Test;
import org.testng.annotations.BeforeMethod;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.*;
import org.openqa.selenium.firefox.FirefoxDriver;

  public class Google {
    private WebDriver driver;
    private String baseUrl;
  
  @BeforeMethod
  public void setUp() throws Exception {
    driver = new FirefoxDriver();
    baseUrl = "<a href="http://google.com.br/" target="_blank" onmousedown="this.href='http://google.com.br/';return true;" onclick="this.href='http://google.com.br/';return true;">http://google.com.br";
    driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
  }

  @Test 
  public void foundGoogle() throws Exception {
    driver.get(baseUrl);
    driver.manage().window().maximize();
    driver.findElement(By.id("gs_tti0")).sendKeys("dfteste");
    driver.findElement(By.id("gbqfba")).click();
    
  }
  
  @Test
  public void clickInTheResult() throws Exception {    
    driver.findElement(By.xpath("//*[@href='<a href="http://br.dir.groups.yahoo.com/group/DFTestes/'" target="_blank" onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Fbr.dir.groups.yahoo.com%2Fgroup%2FDFTestes%2F\47\46sa\75D\46sntz\0751\46usg\75AFQjCNF06Nk1tRSdjZo4emzIOpURREhgAQ';return true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Fbr.dir.groups.yahoo.com%2Fgroup%2FDFTestes%2F\47\46sa\75D\46sntz\0751\46usg\75AFQjCNF06Nk1tRSdjZo4emzIOpURREhgAQ';return true;">http://br.dir.groups.yahoo.com/group/DFTestes/']")).click();

  }
  

 @AfterMethod
    public void tearDown() throws Exception {
    driver.quit();
    }
}

-------------------------------------------------------------

I have only one class with two methods, but, when the script running and execute the method public void clickInTheResult, a new window opens.

how can I run both methods with just one call declared driver.get?

--
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+unsubscribe@googlegroups.com.
To post to this group, send email to [hidden email].
Visit this group at <a href="http://groups.google.com/group/testng-users" target="_blank" onmousedown="this.href='http://groups.google.com/group/testng-users';return true;" onclick="this.href='http://groups.google.com/group/testng-users';return true;">http://groups.google.com/group/testng-users.
For more options, visit <a href="https://groups.google.com/groups/opt_out" target="_blank" onmousedown="this.href='https://groups.google.com/groups/opt_out';return true;" onclick="this.href='https://groups.google.com/groups/opt_out';return true;">https://groups.google.com/groups/opt_out.

--
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 http://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: webdriver + testng

Yevhen Bilevych
Did you manage to solve the issue?

At first look, your solution is still weak - you expect that
PesquisaNoGoogle() is called before clicaNoResultado(). In general the
execution order of testmethods is not guaranteed (through by default it
is alphabetical). You may use dependsOnMethods attribute or
IMethodInterceptor interface.

Thanks,
Yevhen

On 01/09/2014 06:21 PM, raf das wrote:

> after changing the code looked like this:
>
> package MenuAtNeed;
>
> import org.testng.annotations.AfterClass;
> import org.testng.annotations.BeforeClass;
> import org.testng.annotations.Test;
> import java.util.concurrent.TimeUnit;
> import org.openqa.selenium.*;
> import org.openqa.selenium.firefox.FirefoxDriver;
>
>   public class Google {
> private WebDriver driver;
>     private String baseUrl;
>  
>   @BeforeClass
>   public void setUp() throws Exception {
>     driver = new FirefoxDriver();
>     baseUrl = "http://google.com.br";
>     driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
>   }
>
>   @Test
>   public void PesquisaNoGoogle() throws Exception {
>     driver.get(baseUrl);
>     driver.manage().window().maximize();
>     driver.findElement(By.id("gbqfq")).sendKeys("dfteste");
>     driver.findElement(By.id("gbqfba")).click();
>    
>   }
>  
>   @Test
>   public void clicaNoResultado() throws Exception {    
> driver.findElement(By.xpath("//*[@href='http://br.dir.groups.yahoo.com/group/DFTestes/']")).click();
>
>   }
>  
>
> @AfterClass
> public void tearDown() throws Exception {
>     driver.quit();
>     }
> }
>
> the test runs only the first method *public void PesquisaNoGoogle() ,
> *but appears error:
>
> [TestNG] Running:
>  
> C:\Users\Rafael\AppData\Local\Temp\testng-eclipse-1801566236\testng-customsuite.xml
>
> PASSED: clicaNoResultado
> FAILED: PesquisaNoGoogle
> org.openqa.selenium.ElementNotVisibleException: Element is not currently
> visible and so may not be interacted with
> Command duration or timeout: 30.11 seconds
> Build info: version: '2.37.0', revision: 'a7c61cb', time: '2013-10-18
> 17:15:02'
> System info: host: 'Rafael-PC', ip: '192.168.139.1', os.name: 'Windows
> 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.7.0_17'
> Session ID: 6961e54d-0007-477f-898a-639dc80d7f13
> Driver info: org.openqa.selenium.firefox.FirefoxDriver
> Capabilities [{platform=XP, databaseEnabled=true,
> cssSelectorsEnabled=true, javascriptEnabled=true, acceptSslCerts=true,
> handlesAlerts=true, browserName=firefox, browserConnectionEnabled=true,
> nativeEvents=true, webStorageEnabled=true, rotatable=false,
> locationContextEnabled=true, applicationCacheEnabled=true,
> takesScreenshot=true, version=26.0}]
> at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
> at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
> at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
> at java.lang.reflect.Constructor.newInstance(Unknown Source)
> at
> org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:193)
> at
> org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:145)
> at
> org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:554)
> at
> org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:268)
> at
> org.openqa.selenium.remote.RemoteWebElement.click(RemoteWebElement.java:79)
> at MenuAtNeed.Google.PesquisaNoGoogle(Google.java:26)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
> at java.lang.reflect.Method.invoke(Unknown Source)
> at
> org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84)
> at org.testng.internal.Invoker.invokeMethod(Invoker.java:714)
> at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901)
> at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231)
> at
> org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)
> at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
> at org.testng.TestRunner.privateRun(TestRunner.java:767)
> at org.testng.TestRunner.run(TestRunner.java:617)
> at org.testng.SuiteRunner.runTest(SuiteRunner.java:334)
> at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329)
> at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)
> at org.testng.SuiteRunner.run(SuiteRunner.java:240)
> at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
> at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
> at org.testng.TestNG.runSuitesSequentially(TestNG.java:1224)
> at org.testng.TestNG.runSuitesLocally(TestNG.java:1149)
> at org.testng.TestNG.run(TestNG.java:1057)
> at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:111)
> at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:204)
> at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:175)
> Caused by:
> org.openqa.selenium.remote.ErrorHandler$UnknownServerException: Element
> is not currently visible and so may not be interacted with
> Build info: version: '2.37.0', revision: 'a7c61cb', time: '2013-10-18
> 17:15:02'
> System info: host: 'Rafael-PC', ip: '192.168.139.1', os.name: 'Windows
> 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.7.0_17'
> Driver info: driver.version: unknown
> at <anonymous
> class>.fxdriver.preconditions.visible(file:///C:/Users/Rafael/AppData/Local/Temp/anonymous5139849955903958169webdriver-profile/extensions/[hidden email]/components/command_processor.js:8210)
> at <anonymous
> class>.DelayedCommand.prototype.checkPreconditions_(file:///C:/Users/Rafael/AppData/Local/Temp/anonymous5139849955903958169webdriver-profile/extensions/[hidden email]/components/command_processor.js:10827)
> at <anonymous
> class>.DelayedCommand.prototype.executeInternal_/h(file:///C:/Users/Rafael/AppData/Local/Temp/anonymous5139849955903958169webdriver-profile/extensions/[hidden email]/components/command_processor.js:10844)
> at <anonymous
> class>.fxdriver.Timer.prototype.setTimeout/<.notify(file:///C:/Users/Rafael/AppData/Local/Temp/anonymous5139849955903958169webdriver-profile/extensions/[hidden email]/components/command_processor.js:396)
>
>
> ===============================================
>     Default test
>     Tests run: 2, Failures: 1, Skips: 0
> ===============================================
>
>
> ===============================================
> Default suite
> Total tests run: 2, Failures: 1, Skips: 0
> ===============================================
>
> [TestNG] Time taken by org.testng.reporters.jq.Main@58d6147e: 38 ms
> [TestNG] Time taken by org.testng.reporters.XMLReporter@22ea86e3: 13 ms
> [TestNG] Time taken by [FailedReporter passed=0 failed=0 skipped=0]: 6 ms
> [TestNG] Time taken by
> org.testng.reporters.JUnitReportReporter@72440d13: 8 ms
> [TestNG] Time taken by org.testng.reporters.EmailableReporter2@17d7ae87:
> 5 ms
> [TestNG] Time taken by org.testng.reporters.SuiteHTMLReporter@3f38dd0: 34 ms
>
>
> Em quarta-feira, 8 de janeiro de 2014 15h50min33s UTC-2, Niharika_Neo
> escreveu:
>
>     After you changed it to before and afterclass, what's the error you get?
>
>     Regards,
>     Niharika
>
>     On Wednesday, January 8, 2014, raf das wrote:
>
>         Hi friends,
>
>         I have the following script of the example:
>
>         package MenuAtNeed;
>
>         import org.testng.annotations.__AfterMethod;
>         import org.testng.annotations.Test;
>         import org.testng.annotations.__BeforeMethod;
>         import java.util.concurrent.TimeUnit;
>         import org.openqa.selenium.*;
>         import org.openqa.selenium.firefox.__FirefoxDriver;
>
>           public class Google {
>             private WebDriver driver;
>             private String baseUrl;
>          
>           @BeforeMethod
>           public void setUp() throws Exception {
>             driver = new FirefoxDriver();
>             baseUrl = "http://google.com.br <http://google.com.br/>";
>             driver.manage().timeouts().__implicitlyWait(30,
>         TimeUnit.SECONDS);
>           }
>
>           @Test
>           public void foundGoogle() throws Exception {
>             driver.get(baseUrl);
>             driver.manage().window().__maximize();
>             driver.findElement(By.id("gs___tti0")).sendKeys("dfteste");
>             driver.findElement(By.id("__gbqfba")).click();
>            
>           }
>          
>           @Test
>           public void clickInTheResult() throws Exception {    
>            
>         driver.findElement(By.xpath("/__/*[@href='http://br.dir.__groups.yahoo.com/group/__DFTestes/'
>         <http://br.dir.groups.yahoo.com/group/DFTestes/'>]")).click();
>
>           }
>          
>
>          @AfterMethod
>             public void tearDown() throws Exception {
>             driver.quit();
>             }
>         }
>
>         -------------------------------------------------------------
>
>         I have only one class with two methods, but, when the script
>         running and execute the method *public void clickInTheResult, *a
>         new window opens.
>
>         how can I run both methods with just one call declared driver.get?
>
>         --
>         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 http://groups.google.com/group/testng-users
>         <http://groups.google.com/group/testng-users>.
>         For more options, visit https://groups.google.com/groups/opt_out
>         <https://groups.google.com/groups/opt_out>.
>
> --
> 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 http://groups.google.com/group/testng-users.
> For more options, visit https://groups.google.com/groups/opt_out.

--
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 http://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: webdriver + testng

Yevhen Bilevych
In reply to this post by Rafael Carvalho
As of the error "org.openqa.selenium.ElementNotVisibleException: Element
is not currently visible and so may not be interacted with", try out the
solution below:

WebElement element = driver.findElement(By.id("gbqfq"));

//We are not interested in the coordinates. We use side effect -
scrolling viewport to get element visible
((Locatable)element).getCoordinates().inViewPort();

element.sendKeys("dfteste");

Thanks,
Yevhen

On 01/09/2014 06:21 PM, raf das wrote:

> after changing the code looked like this:
>
> package MenuAtNeed;
>
> import org.testng.annotations.AfterClass;
> import org.testng.annotations.BeforeClass;
> import org.testng.annotations.Test;
> import java.util.concurrent.TimeUnit;
> import org.openqa.selenium.*;
> import org.openqa.selenium.firefox.FirefoxDriver;
>
>   public class Google {
> private WebDriver driver;
>     private String baseUrl;
>  
>   @BeforeClass
>   public void setUp() throws Exception {
>     driver = new FirefoxDriver();
>     baseUrl = "http://google.com.br";
>     driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
>   }
>
>   @Test
>   public void PesquisaNoGoogle() throws Exception {
>     driver.get(baseUrl);
>     driver.manage().window().maximize();
>     driver.findElement(By.id("gbqfq")).sendKeys("dfteste");
>     driver.findElement(By.id("gbqfba")).click();
>    
>   }
>  
>   @Test
>   public void clicaNoResultado() throws Exception {    
> driver.findElement(By.xpath("//*[@href='http://br.dir.groups.yahoo.com/group/DFTestes/']")).click();
>
>   }
>  
>
> @AfterClass
> public void tearDown() throws Exception {
>     driver.quit();
>     }
> }
>
> the test runs only the first method *public void PesquisaNoGoogle() ,
> *but appears error:
>
> [TestNG] Running:
>  
> C:\Users\Rafael\AppData\Local\Temp\testng-eclipse-1801566236\testng-customsuite.xml
>
> PASSED: clicaNoResultado
> FAILED: PesquisaNoGoogle
> org.openqa.selenium.ElementNotVisibleException: Element is not currently
> visible and so may not be interacted with
> Command duration or timeout: 30.11 seconds
> Build info: version: '2.37.0', revision: 'a7c61cb', time: '2013-10-18
> 17:15:02'
> System info: host: 'Rafael-PC', ip: '192.168.139.1', os.name: 'Windows
> 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.7.0_17'
> Session ID: 6961e54d-0007-477f-898a-639dc80d7f13
> Driver info: org.openqa.selenium.firefox.FirefoxDriver
> Capabilities [{platform=XP, databaseEnabled=true,
> cssSelectorsEnabled=true, javascriptEnabled=true, acceptSslCerts=true,
> handlesAlerts=true, browserName=firefox, browserConnectionEnabled=true,
> nativeEvents=true, webStorageEnabled=true, rotatable=false,
> locationContextEnabled=true, applicationCacheEnabled=true,
> takesScreenshot=true, version=26.0}]
> at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
> at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
> at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
> at java.lang.reflect.Constructor.newInstance(Unknown Source)
> at
> org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:193)
> at
> org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:145)
> at
> org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:554)
> at
> org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:268)
> at
> org.openqa.selenium.remote.RemoteWebElement.click(RemoteWebElement.java:79)
> at MenuAtNeed.Google.PesquisaNoGoogle(Google.java:26)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
> at java.lang.reflect.Method.invoke(Unknown Source)
> at
> org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84)
> at org.testng.internal.Invoker.invokeMethod(Invoker.java:714)
> at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901)
> at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231)
> at
> org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)
> at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
> at org.testng.TestRunner.privateRun(TestRunner.java:767)
> at org.testng.TestRunner.run(TestRunner.java:617)
> at org.testng.SuiteRunner.runTest(SuiteRunner.java:334)
> at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329)
> at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)
> at org.testng.SuiteRunner.run(SuiteRunner.java:240)
> at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
> at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
> at org.testng.TestNG.runSuitesSequentially(TestNG.java:1224)
> at org.testng.TestNG.runSuitesLocally(TestNG.java:1149)
> at org.testng.TestNG.run(TestNG.java:1057)
> at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:111)
> at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:204)
> at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:175)
> Caused by:
> org.openqa.selenium.remote.ErrorHandler$UnknownServerException: Element
> is not currently visible and so may not be interacted with
> Build info: version: '2.37.0', revision: 'a7c61cb', time: '2013-10-18
> 17:15:02'
> System info: host: 'Rafael-PC', ip: '192.168.139.1', os.name: 'Windows
> 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.7.0_17'
> Driver info: driver.version: unknown
> at <anonymous
> class>.fxdriver.preconditions.visible(file:///C:/Users/Rafael/AppData/Local/Temp/anonymous5139849955903958169webdriver-profile/extensions/[hidden email]/components/command_processor.js:8210)
> at <anonymous
> class>.DelayedCommand.prototype.checkPreconditions_(file:///C:/Users/Rafael/AppData/Local/Temp/anonymous5139849955903958169webdriver-profile/extensions/[hidden email]/components/command_processor.js:10827)
> at <anonymous
> class>.DelayedCommand.prototype.executeInternal_/h(file:///C:/Users/Rafael/AppData/Local/Temp/anonymous5139849955903958169webdriver-profile/extensions/[hidden email]/components/command_processor.js:10844)
> at <anonymous
> class>.fxdriver.Timer.prototype.setTimeout/<.notify(file:///C:/Users/Rafael/AppData/Local/Temp/anonymous5139849955903958169webdriver-profile/extensions/[hidden email]/components/command_processor.js:396)
>
>
> ===============================================
>     Default test
>     Tests run: 2, Failures: 1, Skips: 0
> ===============================================
>
>
> ===============================================
> Default suite
> Total tests run: 2, Failures: 1, Skips: 0
> ===============================================
>
> [TestNG] Time taken by org.testng.reporters.jq.Main@58d6147e: 38 ms
> [TestNG] Time taken by org.testng.reporters.XMLReporter@22ea86e3: 13 ms
> [TestNG] Time taken by [FailedReporter passed=0 failed=0 skipped=0]: 6 ms
> [TestNG] Time taken by
> org.testng.reporters.JUnitReportReporter@72440d13: 8 ms
> [TestNG] Time taken by org.testng.reporters.EmailableReporter2@17d7ae87:
> 5 ms
> [TestNG] Time taken by org.testng.reporters.SuiteHTMLReporter@3f38dd0: 34 ms
>
>
> Em quarta-feira, 8 de janeiro de 2014 15h50min33s UTC-2, Niharika_Neo
> escreveu:
>
>     After you changed it to before and afterclass, what's the error you get?
>
>     Regards,
>     Niharika
>
>     On Wednesday, January 8, 2014, raf das wrote:
>
>         Hi friends,
>
>         I have the following script of the example:
>
>         package MenuAtNeed;
>
>         import org.testng.annotations.__AfterMethod;
>         import org.testng.annotations.Test;
>         import org.testng.annotations.__BeforeMethod;
>         import java.util.concurrent.TimeUnit;
>         import org.openqa.selenium.*;
>         import org.openqa.selenium.firefox.__FirefoxDriver;
>
>           public class Google {
>             private WebDriver driver;
>             private String baseUrl;
>          
>           @BeforeMethod
>           public void setUp() throws Exception {
>             driver = new FirefoxDriver();
>             baseUrl = "http://google.com.br <http://google.com.br/>";
>             driver.manage().timeouts().__implicitlyWait(30,
>         TimeUnit.SECONDS);
>           }
>
>           @Test
>           public void foundGoogle() throws Exception {
>             driver.get(baseUrl);
>             driver.manage().window().__maximize();
>             driver.findElement(By.id("gs___tti0")).sendKeys("dfteste");
>             driver.findElement(By.id("__gbqfba")).click();
>            
>           }
>          
>           @Test
>           public void clickInTheResult() throws Exception {    
>            
>         driver.findElement(By.xpath("/__/*[@href='http://br.dir.__groups.yahoo.com/group/__DFTestes/'
>         <http://br.dir.groups.yahoo.com/group/DFTestes/'>]")).click();
>
>           }
>          
>
>          @AfterMethod
>             public void tearDown() throws Exception {
>             driver.quit();
>             }
>         }
>
>         -------------------------------------------------------------
>
>         I have only one class with two methods, but, when the script
>         running and execute the method *public void clickInTheResult, *a
>         new window opens.
>
>         how can I run both methods with just one call declared driver.get?
>
>         --
>         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 http://groups.google.com/group/testng-users
>         <http://groups.google.com/group/testng-users>.
>         For more options, visit https://groups.google.com/groups/opt_out
>         <https://groups.google.com/groups/opt_out>.
>
> --
> 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 http://groups.google.com/group/testng-users.
> For more options, visit https://groups.google.com/groups/opt_out.

--
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 http://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/groups/opt_out.