Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 5fc5a84

Browse files
committed
Update Browsers
1 parent 5270687 commit 5fc5a84

File tree

11 files changed

+149
-25
lines changed

11 files changed

+149
-25
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package org.sayem.webdriver.annotations;
2+
3+
import org.sayem.webdriver.Repository;
4+
5+
import java.lang.annotation.Retention;
6+
import java.lang.annotation.Target;
7+
8+
import static java.lang.annotation.ElementType.METHOD;
9+
import static java.lang.annotation.RetentionPolicy.RUNTIME;
10+
import static org.sayem.webdriver.Repository.CHROME;
11+
12+
/**
13+
* Created by sayem on 2/24/16.
14+
*/
15+
@Retention(RUNTIME)
16+
@Target({METHOD})
17+
public @interface Chrome {
18+
Repository browser() default CHROME;
19+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package org.sayem.webdriver.annotations;
2+
3+
import org.sayem.webdriver.Repository;
4+
5+
import java.lang.annotation.Retention;
6+
import java.lang.annotation.Target;
7+
8+
import static java.lang.annotation.ElementType.METHOD;
9+
import static java.lang.annotation.RetentionPolicy.RUNTIME;
10+
import static org.sayem.webdriver.Repository.FIREFOX;
11+
12+
/**
13+
* Created by sayem on 2/24/16.
14+
*/
15+
@Retention(RUNTIME)
16+
@Target({METHOD})
17+
public @interface Firefox {
18+
Repository browser() default FIREFOX;
19+
}
20+
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package org.sayem.webdriver.annotations;
2+
3+
import org.sayem.webdriver.Repository;
4+
5+
import java.lang.annotation.Retention;
6+
import java.lang.annotation.Target;
7+
8+
import static java.lang.annotation.ElementType.METHOD;
9+
import static java.lang.annotation.RetentionPolicy.RUNTIME;
10+
import static org.sayem.webdriver.Repository.IE;
11+
12+
/**
13+
* Created by sayem on 2/24/16.
14+
*/
15+
@Retention(RUNTIME)
16+
@Target({METHOD})
17+
public @interface InternetExplorer {
18+
Repository browser() default IE;
19+
}
20+
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package org.sayem.webdriver.annotations;
2+
3+
import org.sayem.webdriver.Repository;
4+
5+
import java.lang.annotation.Retention;
6+
import java.lang.annotation.Target;
7+
8+
import static java.lang.annotation.ElementType.METHOD;
9+
import static java.lang.annotation.RetentionPolicy.RUNTIME;
10+
import static org.sayem.webdriver.Repository.SAFARI;
11+
12+
/**
13+
* Created by sayem on 2/24/16.
14+
*/
15+
@Retention(RUNTIME)
16+
@Target({METHOD})
17+
public @interface Safari {
18+
Repository browser() default SAFARI;
19+
}
20+

‎src/main/java/org/sayem/webdriver/annotations/WebSite.java renamed to ‎src/main/java/org/sayem/webdriver/annotations/Url.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@
1414
*/
1515
@Retention(RUNTIME)
1616
@Target({METHOD})
17-
public @interface WebSite {
17+
public @interface Url {
1818
Repository value() default MADISON_ISLAND;
1919
}

‎src/main/java/org/sayem/webdriver/listeners/TestNGListener.java

Lines changed: 43 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package org.sayem.webdriver.listeners;
22

3-
import org.sayem.webdriver.annotations.Browser;
4-
import org.sayem.webdriver.annotations.WebSite;
3+
import org.sayem.webdriver.annotations.*;
54
import org.testng.*;
65

76
import java.lang.annotation.Annotation;
@@ -13,28 +12,64 @@ public class TestNGListener implements IInvokedMethodListener2 {
1312

1413
private String environment;
1514
private String browser;
15+
private String chrome;
16+
private String ie;
17+
private String firefox;
18+
private String safari;
1619

1720

1821
@Override
1922
public void beforeInvocation(IInvokedMethod method, ITestResult testResult, ITestContext context) {
2023

2124
for (ITestNGMethod m : context.getAllTestMethods()) {
22-
if (m.getConstructorOrMethod().getMethod().isAnnotationPresent(WebSite.class) &&
25+
if (m.getConstructorOrMethod().getMethod().isAnnotationPresent(Url.class) &&
2326
m.getConstructorOrMethod().getMethod().isAnnotationPresent(Browser.class)) {
24-
environment = m.getConstructorOrMethod().getMethod().getAnnotation(WebSite.class).value().getValue();
27+
environment = m.getConstructorOrMethod().getMethod().getAnnotation(Url.class).value().getValue();
2528
browser = m.getConstructorOrMethod().getMethod().getAnnotation(Browser.class).browser().getValue();
26-
} else if (m.getConstructorOrMethod().getMethod().isAnnotationPresent(WebSite.class)) {
27-
environment = m.getConstructorOrMethod().getMethod().getAnnotation(WebSite.class).value().getValue();
29+
} else if (m.getConstructorOrMethod().getMethod().isAnnotationPresent(Url.class) &&
30+
m.getConstructorOrMethod().getMethod().isAnnotationPresent(Chrome.class)) {
31+
environment = m.getConstructorOrMethod().getMethod().getAnnotation(Url.class).value().getValue();
32+
chrome = m.getConstructorOrMethod().getMethod().getAnnotation(Chrome.class).browser().getValue();
33+
} else if (m.getConstructorOrMethod().getMethod().isAnnotationPresent(Url.class) &&
34+
m.getConstructorOrMethod().getMethod().isAnnotationPresent(Firefox.class)) {
35+
environment = m.getConstructorOrMethod().getMethod().getAnnotation(Url.class).value().getValue();
36+
firefox = m.getConstructorOrMethod().getMethod().getAnnotation(Firefox.class).browser().getValue();
37+
} else if (m.getConstructorOrMethod().getMethod().isAnnotationPresent(Url.class) &&
38+
m.getConstructorOrMethod().getMethod().isAnnotationPresent(Safari.class)) {
39+
environment = m.getConstructorOrMethod().getMethod().getAnnotation(Url.class).value().getValue();
40+
safari = m.getConstructorOrMethod().getMethod().getAnnotation(Safari.class).browser().getValue();
41+
} else if (m.getConstructorOrMethod().getMethod().isAnnotationPresent(Url.class) &&
42+
m.getConstructorOrMethod().getMethod().isAnnotationPresent(InternetExplorer.class)) {
43+
environment = m.getConstructorOrMethod().getMethod().getAnnotation(Url.class).value().getValue();
44+
ie = m.getConstructorOrMethod().getMethod().getAnnotation(InternetExplorer.class).browser().getValue();
45+
} else if (m.getConstructorOrMethod().getMethod().isAnnotationPresent(Url.class)) {
46+
environment = m.getConstructorOrMethod().getMethod().getAnnotation(Url.class).value().getValue();
2847
} else if (m.getConstructorOrMethod().getMethod().isAnnotationPresent(Browser.class)) {
2948
browser = m.getConstructorOrMethod().getMethod().getAnnotation(Browser.class).browser().getValue();
3049
}
3150
}
3251

33-
if (method.isTestMethod() && annotationPresent(method, WebSite.class) &&
52+
if (method.isTestMethod() && annotationPresent(method, Url.class) &&
3453
method.isTestMethod() && annotationPresent(method, Browser.class)) {
3554
System.setProperty("seleniumUrl", environment);
3655
System.setProperty("browser", browser);
37-
} else if (method.isTestMethod() && annotationPresent(method, WebSite.class)) {
56+
} else if (method.isTestMethod() && annotationPresent(method, Url.class) &&
57+
method.isTestMethod() && annotationPresent(method, Chrome.class)) {
58+
System.setProperty("seleniumUrl", environment);
59+
System.setProperty("browser", chrome);
60+
} else if (method.isTestMethod() && annotationPresent(method, Url.class) &&
61+
method.isTestMethod() && annotationPresent(method, Firefox.class)) {
62+
System.setProperty("seleniumUrl", environment);
63+
System.setProperty("browser", firefox);
64+
} else if (method.isTestMethod() && annotationPresent(method, Url.class) &&
65+
method.isTestMethod() && annotationPresent(method, Safari.class)) {
66+
System.setProperty("seleniumUrl", environment);
67+
System.setProperty("browser", safari);
68+
} else if (method.isTestMethod() && annotationPresent(method, Url.class) &&
69+
method.isTestMethod() && annotationPresent(method, InternetExplorer.class)) {
70+
System.setProperty("seleniumUrl", environment);
71+
System.setProperty("browser", ie);
72+
} else if (method.isTestMethod() && annotationPresent(method, Url.class)) {
3873
System.setProperty("seleniumUrl", environment);
3974
} else if (method.isTestMethod() && annotationPresent(method, Browser.class)) {
4075
System.setProperty("browser", browser);

‎src/test/java/org/sayem/webdriver/testcases/internet/BrokenImageTest.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
package org.sayem.webdriver.testcases.internet;
22

33
import org.sayem.webdriver.TestBase;
4-
import org.sayem.webdriver.annotations.Browser;
5-
import org.sayem.webdriver.annotations.WebSite;
4+
import org.sayem.webdriver.annotations.Chrome;
5+
import org.sayem.webdriver.annotations.Firefox;
6+
import org.sayem.webdriver.annotations.Safari;
7+
import org.sayem.webdriver.annotations.Url;
68
import org.sayem.webdriver.pages.internet.HomePage;
79
import org.testng.annotations.Test;
810

@@ -13,8 +15,8 @@
1315
*/
1416
public class BrokenImageTest extends TestBase{
1517

16-
@Browser(browser = FIREFOX)
17-
@WebSite(value = THE_INTERNET)
18+
@Safari
19+
@Url(value = THE_INTERNET)
1820
@Test
1921
public void brokenImageTest(){
2022
HomePage page = pageFactory(HomePage.class);

‎src/test/java/org/sayem/webdriver/testcases/internet/CheckboxTest.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
import org.sayem.webdriver.TestBase;
44
import org.sayem.webdriver.annotations.Browser;
5-
import org.sayem.webdriver.annotations.WebSite;
5+
import org.sayem.webdriver.annotations.Chrome;
6+
import org.sayem.webdriver.annotations.Url;
67
import org.sayem.webdriver.pages.internet.HomePage;
78
import org.testng.annotations.Test;
89

@@ -21,8 +22,8 @@ public class CheckboxTest extends TestBase{
2122
* mvn clean install -Dbrowser=phantomjs
2223
*/
2324

24-
@Browser(browser = CHROME)
25-
@WebSite(value = THE_INTERNET)
25+
@Chrome
26+
@Url(value = THE_INTERNET)
2627
@Test
2728
public void checkboxTest(){
2829
HomePage page = pageFactory(HomePage.class);

‎src/test/java/org/sayem/webdriver/testcases/internet/DragAndDropTest.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
import org.sayem.webdriver.TestBase;
44
import org.sayem.webdriver.annotations.Browser;
5-
import org.sayem.webdriver.annotations.WebSite;
5+
import org.sayem.webdriver.annotations.Chrome;
6+
import org.sayem.webdriver.annotations.Safari;
7+
import org.sayem.webdriver.annotations.Url;
68
import org.sayem.webdriver.pages.internet.HomePage;
79
import org.testng.annotations.Test;
810

@@ -14,8 +16,8 @@
1416
public class DragAndDropTest extends TestBase{
1517

1618
@Test
17-
@Browser(browser = CHROME)
18-
@WebSite(value = THE_INTERNET)
19+
@Chrome
20+
@Url(value = THE_INTERNET)
1921
public void checkboxTest(){
2022
HomePage page = pageFactory(HomePage.class);
2123
page.dragAndDrop()

‎src/test/java/org/sayem/webdriver/testcases/internet/DropdownTest.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
import org.sayem.webdriver.TestBase;
44
import org.sayem.webdriver.annotations.Browser;
5-
import org.sayem.webdriver.annotations.WebSite;
5+
import org.sayem.webdriver.annotations.Firefox;
6+
import org.sayem.webdriver.annotations.Url;
67
import org.sayem.webdriver.pages.internet.HomePage;
78
import org.testng.annotations.Test;
89

@@ -26,8 +27,8 @@ public class DropdownTest extends TestBase{
2627
*/
2728

2829
@Test
29-
@Browser(browser = CHROME)
30-
@WebSite(value = THE_INTERNET)
30+
@Firefox
31+
@Url(value = THE_INTERNET)
3132
public void dropdownTest(){
3233
HomePage page = pageFactory(HomePage.class);
3334
page.dropdown()

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /