- mylogin99
- Posts : 3
Join date : 2012-01-24
Selenium IDE and Selenium Webdriver incompatibility.
Thu Jan 26, 2012 6:35 pm
Hello.
I've composed test suite in IDE which has two test cases inside. When I run this test suite in IDE test cases are being executed in the same browser window(without closing browser window after each test case and opening new one for next). Surprisingly, when i export test suite and test cases to Webdriver code, and then run my code , each test case of my test suite is being executed in a new window. After analyzing my java code(exported from IDE) I've noticed that for each test case new driver created(FirefoxDriver driver = new FirefoxDriver() ) and quited (driver.quit() ) at the end of test case, thats why new browser opens and exits for each test case.
So my questions:
1.Why there is such an incompatibility between IDE and Webdriver???
2. Can I modify my java code so that all my test cases be executed in the same window as in IDE ???
Thanks in advance.
I've composed test suite in IDE which has two test cases inside. When I run this test suite in IDE test cases are being executed in the same browser window(without closing browser window after each test case and opening new one for next). Surprisingly, when i export test suite and test cases to Webdriver code, and then run my code , each test case of my test suite is being executed in a new window. After analyzing my java code(exported from IDE) I've noticed that for each test case new driver created(FirefoxDriver driver = new FirefoxDriver() ) and quited (driver.quit() ) at the end of test case, thats why new browser opens and exits for each test case.
So my questions:
1.Why there is such an incompatibility between IDE and Webdriver???
2. Can I modify my java code so that all my test cases be executed in the same window as in IDE ???
Thanks in advance.
- man2auto
- Posts : 1
Join date : 2012-01-30
Re: Selenium IDE and Selenium Webdriver incompatibility.
Mon Jan 30, 2012 7:16 pm
Actually you are right.
If you notice, in your java code, the "FirefoxDriver driver = new FirefoxDriver()" statement would be inside a method (called 'setUp' most probably). This method would have an "@Before" annotation.
So all you have to do is move this "FirefoxDriver driver = new FirefoxDriver()" statement to a method above it and make it a static method. Annotate that method with "@BeforeClass" annotation
for eg
@BeforeClass
public static void oneTimeSetup(){
"FirefoxDriver driver = new FirefoxDriver()"
}
Having the rest of the methods intact would be sufficient.
It would be good if you could paste a sample test class, So that we can see if anything more could be added.
If you notice, in your java code, the "FirefoxDriver driver = new FirefoxDriver()" statement would be inside a method (called 'setUp' most probably). This method would have an "@Before" annotation.
So all you have to do is move this "FirefoxDriver driver = new FirefoxDriver()" statement to a method above it and make it a static method. Annotate that method with "@BeforeClass" annotation
for eg
@BeforeClass
public static void oneTimeSetup(){
"FirefoxDriver driver = new FirefoxDriver()"
}
Having the rest of the methods intact would be sufficient.
It would be good if you could paste a sample test class, So that we can see if anything more could be added.
- qappbcAmateur
- Posts : 38
Join date : 2011-10-13
Re: Selenium IDE and Selenium Webdriver incompatibility.
Mon Jan 30, 2012 11:22 pm
It is because in exporting to the JUnit or TestNG framework that the annotation of @Before, etc. is included in the exported code. By design, it is assumed when selecting either of these export choices you would take advantage of them.
But it is not required to use those annotations. You could transfer needed code inside the annotation sections to the main body of your test case code and it would work as you want it to.
But it is not required to use those annotations. You could transfer needed code inside the annotation sections to the main body of your test case code and it would work as you want it to.
- I downloaded and installed Selenium WebDriver Jar files in my Eclipse, but still i am facing issues and couldn't run the webdriver scripsts.
- Selenium IDE generated testcase script is not working in Selenium Webdriver
- Selenium webdriver Error - "Could not contact Selenium Server".
- Using Selenium Webdriver through selenium with fancy reporting
- Selenium RC with NUnit throwing error - File does not exist. File 'c:\Projects\WebDriver\trunk\src\Selenium.Core\HttpCommandProcessor.cs'
Permissions in this forum:
You cannot reply to topics in this forum