Skip to content

Commit 530a007

Browse files
author
Mayur Shah
committed
fixing the setup
1 parent f593064 commit 530a007

13 files changed

+124
-155
lines changed

Page Object Model/screenShot/package-info.java

Lines changed: 0 additions & 8 deletions
This file was deleted.

Page Object Model/testcases/OrangeHRMLoginTest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import org.openqa.selenium.WebDriver;
55

66
import org.openqa.selenium.firefox.FirefoxDriver;
7+
import org.openqa.selenium.firefox.FirefoxOptions;
78
import org.openqa.selenium.remote.DesiredCapabilities;
89
import org.testng.Assert;
910

@@ -32,8 +33,8 @@ public class OrangeHRMLoginTest {
3233
public void setup(){
3334
DesiredCapabilities capabilities = DesiredCapabilities.firefox();
3435
capabilities.setCapability("marionette", false);
35-
36-
driver = new FirefoxDriver(capabilities);
36+
FirefoxOptions options = new FirefoxOptions(capabilities);
37+
driver = new FirefoxDriver(options);
3738

3839
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
3940

Page Object Model/testcases/OrangeHRMTCPF.java

Lines changed: 43 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -5,96 +5,88 @@
55
import org.openqa.selenium.WebDriver;
66

77
import org.openqa.selenium.firefox.FirefoxDriver;
8+
import org.openqa.selenium.firefox.FirefoxOptions;
89
import org.openqa.selenium.remote.DesiredCapabilities;
910
import org.testng.Assert;
1011

1112
import org.testng.annotations.BeforeTest;
1213

1314
import org.testng.annotations.Test;
1415

15-
1616
import pageFactory.OrangeHRMHomePF;
1717
import pageFactory.OrangeHRMLoginPF;
1818
import screenShot.ScreenShot;
1919

2020
public class OrangeHRMTCPF {
21-
21+
2222
WebDriver driver;
2323

2424
OrangeHRMLoginPF objLogin;
2525

2626
OrangeHRMHomePF objHomePage;
27-
28-
ScreenShot objScreenShot;
2927

30-
28+
ScreenShot objScreenShot;
3129

32-
@BeforeTest
30+
@BeforeTest
3331

34-
public void setup() throws Exception{
35-
DesiredCapabilities capabilities = DesiredCapabilities.firefox();
32+
public void setup() throws Exception {
33+
DesiredCapabilities capabilities = DesiredCapabilities.firefox();
3634
capabilities.setCapability("marionette", false);
35+
FirefoxOptions options = new FirefoxOptions(capabilities);
36+
driver = new FirefoxDriver(options);
3737

38-
driver = new FirefoxDriver(capabilities);
39-
40-
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
38+
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
4139

42-
driver.get("http://demo.ohrm.softwaretestingboard.com");
43-
44-
40+
driver.get("http://demo.ohrm.softwaretestingboard.com");
4541

46-
}
42+
}
4743

48-
/**
44+
/**
45+
*
46+
* This test case will login in http://demo.ohrm.softwaretestingboard.com
47+
*
48+
* Verify Home page title as "Welcome Hemant"
49+
*
50+
* Login to application
51+
*
52+
* @throws Exception
53+
*
54+
*
55+
*/
4956

50-
* This test case will login in http://demo.ohrm.softwaretestingboard.com
57+
@Test(priority = 0)
5158

52-
* Verify Home page title as "Welcome Hemant"
59+
public void test_Home_Page_Appear_Correct() throws Exception {
5360

54-
* Login to application
55-
* @throws Exception
61+
objScreenShot = new ScreenShot(driver);
62+
// Taking screen shot
63+
objScreenShot.takeScreenShot(driver);
5664

65+
// Create Login Page object
5766

58-
*/
67+
objLogin = new OrangeHRMLoginPF(driver);
5968

60-
@Test(priority=0)
69+
// login to application
6170

62-
public void test_Home_Page_Appear_Correct() throws Exception{
63-
64-
65-
objScreenShot = new ScreenShot(driver);
66-
//Taking screen shot
67-
objScreenShot.takeScreenShot(driver);
71+
objLogin.LoginOrangeHRM("hemant", "hemant@123");
6872

69-
//Create Login Page object
73+
// go the next page
7074

71-
objLogin = new OrangeHRMLoginPF(driver);
75+
objHomePage = new OrangeHRMHomePF(driver);
7276

77+
// Verify home page
7378

79+
Assert.assertTrue(objHomePage.getHomePageDashboardUserName().contains("Welcome Hemant"));
7480

75-
//login to application
81+
// Taking screen shot of home page
82+
objScreenShot.takeScreenShot(driver);
7683

77-
objLogin.LoginOrangeHRM("hemant", "hemant@123");
84+
// Logout from OrangeHRM
85+
objHomePage.applicationLogoutAction();
7886

79-
// go the next page
87+
// Taking screen shot of login page
88+
objScreenShot.takeScreenShot(driver);
8089

81-
objHomePage = new OrangeHRMHomePF(driver);
90+
}
8291

83-
//Verify home page
84-
85-
Assert.assertTrue(objHomePage.getHomePageDashboardUserName().contains("Welcome Hemant"));
86-
87-
//Taking screen shot of home page
88-
objScreenShot.takeScreenShot(driver);
89-
90-
91-
// Logout from OrangeHRM
92-
objHomePage.applicationLogoutAction();
93-
94-
//Taking screen shot of login page
95-
objScreenShot.takeScreenShot(driver);
96-
97-
98-
}
99-
10092
}

Page Object Model/testcases/package-info.java

Lines changed: 0 additions & 8 deletions
This file was deleted.
Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,36 @@
11
package webPages;
2+
23
import org.openqa.selenium.By;
34

45
import org.openqa.selenium.WebDriver;
56

67
public class OrangeHRMHomePage {
7-
8+
89
WebDriver driver;
910

10-
By homePageUserName = By.linkText("Welcome Hemant");
11-
12-
By LogoutLink = By.linkText("Logout");
11+
By homePageUserName = By.linkText("Welcome Hemant");
12+
13+
By LogoutLink = By.linkText("Logout");
14+
15+
public OrangeHRMHomePage(WebDriver driver) {
16+
17+
this.driver = driver;
1318

14-
19+
}
1520

16-
public OrangeHRMHomePage(WebDriver driver){
21+
// Get the User name from Home Page
1722

18-
this.driver = driver;
23+
public String getHomePageDashboardUserName() {
1924

20-
}
21-
22-
//Get the User name from Home Page
25+
return driver.findElement(homePageUserName).getText();
2326

24-
public String getHomePageDashboardUserName(){
27+
}
2528

26-
return driver.findElement(homePageUserName).getText();
29+
// Logout from orangeHRM application
2730

28-
}
29-
30-
// Logout from orangeHRM application
31-
32-
public void applicationLogoutAction(){
33-
driver.findElement(homePageUserName).click();
34-
driver.findElement(LogoutLink).click();
35-
}
31+
public void applicationLogoutAction() {
32+
driver.findElement(homePageUserName).click();
33+
driver.findElement(LogoutLink).click();
34+
}
3635

3736
}
Lines changed: 38 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,87 +1,74 @@
11
package webPages;
2+
23
import org.openqa.selenium.By;
34

45
import org.openqa.selenium.WebDriver;
56

67
public class OrangeHRMLoginPage {
78
WebDriver driver;
8-
9-
By userOrangeHRM= By.id("txtUsername");
10-
11-
By passwordOrangeHRM = By.name("txtPassword");
12-
13-
14-
By login = By.id("btnLogin");
15-
16-
17-
public OrangeHRMLoginPage(WebDriver driver){
18-
19-
this.driver = driver;
20-
21-
}
22-
23-
//Set user name in textbox
249

25-
public void setUserName(String strUserName){
10+
By userOrangeHRM = By.id("txtUsername");
2611

27-
driver.findElement(userOrangeHRM).sendKeys(strUserName);
12+
By passwordOrangeHRM = By.name("txtPassword");
2813

29-
}
14+
By login = By.id("btnLogin");
3015

31-
16+
public OrangeHRMLoginPage(WebDriver driver) {
3217

33-
//Set password in password textbox
18+
this.driver = driver;
3419

35-
public void setPassword(String strPassword){
20+
}
3621

37-
driver.findElement(passwordOrangeHRM).sendKeys(strPassword);
22+
// Set user name in textbox
3823

39-
}
24+
public void setUserName(String strUserName) {
4025

41-
26+
driver.findElement(userOrangeHRM).sendKeys(strUserName);
4227

43-
//Click on login button
28+
}
4429

45-
public void clickLogin(){
30+
// Set password in password textbox
4631

47-
driver.findElement(login).click();
32+
public void setPassword(String strPassword) {
4833

49-
}
34+
driver.findElement(passwordOrangeHRM).sendKeys(strPassword);
5035

51-
36+
}
5237

38+
// Click on login button
5339

40+
public void clickLogin() {
5441

55-
/**
42+
driver.findElement(login).click();
5643

57-
* This POM method will be exposed in test case to login in the application
44+
}
5845

59-
* @param strUserName
46+
/**
47+
*
48+
* This POM method will be exposed in test case to login in the application
49+
*
50+
* @param strUserName
51+
*
52+
* @param strPasword
53+
*
54+
* @return
55+
*
56+
*/
6057

61-
* @param strPasword
58+
public void LoginOrangeHRM(String strUserName, String strPasword) {
6259

63-
* @return
60+
// Fill user name
6461

65-
*/
62+
this.setUserName(strUserName);
6663

67-
public void LoginOrangeHRM(String strUserName,String strPasword){
64+
// Fill password
6865

69-
//Fill user name
66+
this.setPassword(strPasword);
7067

71-
this.setUserName(strUserName);
68+
// Click Login button
7269

73-
//Fill password
70+
this.clickLogin();
7471

75-
this.setPassword(strPasword);
76-
77-
//Click Login button
78-
79-
this.clickLogin();
80-
81-
82-
83-
}
72+
}
8473

8574
}
86-
87-

src/com/softwaretestingboard/examples/testng/CrossBTestNG.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import org.openqa.selenium.WebDriver;
66
import org.openqa.selenium.WebElement;
77
import org.openqa.selenium.firefox.FirefoxDriver;
8+
import org.openqa.selenium.firefox.FirefoxOptions;
89
import org.openqa.selenium.remote.DesiredCapabilities;
910
import org.testng.Assert;
1011
import org.testng.annotations.AfterClass;
@@ -33,15 +34,16 @@ public void beforeTest(String browser) {
3334

3435
DesiredCapabilities capabilities = DesiredCapabilities.firefox();
3536
capabilities.setCapability("marionette", false);
36-
driver = new FirefoxDriver(capabilities);
37+
FirefoxOptions options = new FirefoxOptions(capabilities);
38+
driver = new FirefoxDriver(options);
3739

3840
// If browser is Chrome, then do this
3941

4042
} else if (browser.equalsIgnoreCase("chrome")) {
4143

4244
// Here I am setting up the path for my IEDriver
4345

44-
String exePath = "C:\\Users\\HEMANT\\Desktop\\Softwares\\selenium-java-3.4.0\\chromedriver_win32\\chromedriver.exe";
46+
String exePath = "drivers\\chromedriver_win32\\chromedriver.exe";
4547
System.setProperty("webdriver.chrome.driver", exePath);
4648
driver = new ChromeDriver();
4749

0 commit comments

Comments
 (0)