Skip to content

Commit c0f8114

Browse files
author
Manish Goyal
committed
adding fixes for firefox
1 parent ce6439f commit c0f8114

File tree

7 files changed

+23
-11
lines changed

7 files changed

+23
-11
lines changed

src/test/java/com/javacodegeeks/testng/selenium/TestNGSeleniumBrowserCfgExample.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public class TestNGSeleniumBrowserCfgExample {
2525
@BeforeTest
2626
public void initDriver(@Optional("firefox") String browser) throws Exception {
2727

28-
System.out.println("You are testing on browser " + browser);
28+
System.out.println("You are testing on browser " + browser);
2929
browser = browser.toLowerCase();
3030

3131
if (browser.equals("chrome")) {

src/test/java/org/openqa/selenium/testing/example/GoogleSuggest.java

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,23 @@
66
import org.openqa.selenium.WebDriver;
77
import org.openqa.selenium.WebElement;
88
import org.openqa.selenium.firefox.FirefoxDriver;
9+
import org.testng.annotations.AfterSuite;
10+
import org.testng.annotations.BeforeSuite;
911
import org.testng.annotations.Test;
1012

1113
public class GoogleSuggest {
1214

15+
WebDriver driver;
16+
17+
@BeforeSuite
18+
public void initDriver() throws Exception {
19+
System.out.println("You are testing in firefox");
20+
driver = new FirefoxDriver();
21+
}
1322
@Test
1423
public void googleSuggest() throws Exception {
15-
// The Firefox driver supports javascript
16-
WebDriver driver = new FirefoxDriver();
17-
18-
// Go to the Google Suggest home page
24+
25+
// Go to the Google Suggest home page
1926
driver.get("http://www.google.com/webhp?complete=1&hl=en");
2027

2128
// Enter the query string "Cheese"
@@ -40,6 +47,11 @@ public void googleSuggest() throws Exception {
4047
System.out.println(suggestion.getText());
4148
}
4249

43-
driver.quit();
4450
}
51+
52+
@AfterSuite
53+
public void quitDriver() throws Exception {
54+
if(driver != null)
55+
driver.quit();
56+
}
4557
}
Binary file not shown.
10.3 MB
Binary file not shown.
Binary file not shown.

src/test/resources/com/javacodegeeks/testng/selenium/testngGoogleSuggest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<suite name="TestNgSeleniumSuite" parallel="false">
33
<test name="Test">
44
<classes>
5-
<class name="org.openqa.selenium.example.GoogleSuggest"/>
5+
<class name="org.openqa.selenium.testing.example.GoogleSuggest"/>
66
</classes>
77
</test> <!-- Test -->
88
</suite> <!-- GoogleSuggestSuite -->

testng.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@
1919
</test>
2020

2121
<test name="Test">
22-
<classes>
22+
<classes>
23+
<class name="com.javacodegeeks.testng.selenium.TestNGSeleniumBrowserCfgExample" />
2324
<class name="com.javacodegeeks.testng.selenium.TestNGExample"/>
2425
<class name="com.javacodegeeks.testng.selenium.TestNGSeleniumDataDrivenSearchExample"/>
2526
<class name="com.javacodegeeks.testng.selenium.TestNGSeleniumSimpleSearchExample"/>
2627
<class name="com.javacodegeeks.testng.selenium.TestNGSeleniumDriverInjectionExample"/>
28+
<class name="org.openqa.selenium.testing.example.GoogleSuggest"/>
2729
<class name="com.javacodegeeks.testng.selenium.TestNGSeleniumDependentMethodExample"/>
28-
</classes>
30+
</classes>
2931
</test> <!-- Test -->
3032

31-
32-
3333
</suite> <!-- Suite -->

0 commit comments

Comments
 (0)