Skip to content

Commit 219826b

Browse files
Fix buildname (#12)
Co-authored-by: Roy <dekleijn.roy@gmail.com>
1 parent 7b76012 commit 219826b

15 files changed

Lines changed: 52 additions & 41 deletions

File tree

build.gradle

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ tasks.register('bstack-single', Test) {
9090
include '**/OrderTest.class'
9191
}
9292
systemProperty "environment", "remote"
93-
systemProperty "test", "single"
93+
systemProperty "testType", "single"
9494
testLogging {
9595
events "PASSED", "FAILED", "SKIPPED"
9696
}
@@ -106,7 +106,7 @@ tasks.register('bstack-local', Test) {
106106
include '**/OrderTest.class'
107107
}
108108
systemProperty "environment", "remote"
109-
systemProperty "test", "local"
109+
systemProperty "testType", "local"
110110
testLogging {
111111
events "PASSED", "FAILED", "SKIPPED"
112112
}
@@ -119,7 +119,7 @@ tasks.register('bstack-local-parallel', Test) {
119119
listeners.add("com.browserstack.test.utils.BrowserstackTestStatusListener")
120120
}
121121
systemProperty "environment", "remote"
122-
systemProperty "test", "local"
122+
systemProperty "testType", "local"
123123
testLogging {
124124
events "PASSED", "FAILED", "SKIPPED"
125125
}
@@ -133,7 +133,7 @@ tasks.register('bstack-local-parallel-browsers', Test) {
133133
listeners.add("com.browserstack.test.utils.BrowserstackTestStatusListener")
134134
}
135135
systemProperty "environment", "remote"
136-
systemProperty "test", "local"
136+
systemProperty "testType", "local"
137137
testLogging {
138138
events "PASSED", "FAILED", "SKIPPED"
139139
}
@@ -146,7 +146,7 @@ tasks.register('bstack-parallel', Test) {
146146
listeners.add("com.browserstack.test.utils.BrowserstackTestStatusListener")
147147
}
148148
systemProperty "environment", "remote"
149-
systemProperty "test", "parallel"
149+
systemProperty "testType", "parallel"
150150
testLogging {
151151
events "PASSED", "FAILED", "SKIPPED"
152152
}
@@ -160,7 +160,7 @@ tasks.register('bstack-parallel-browsers', Test) {
160160
listeners.add("com.browserstack.test.utils.BrowserstackTestStatusListener")
161161
}
162162
systemProperty "environment", "remote"
163-
systemProperty "test", "parallel"
163+
systemProperty "testType", "parallel"
164164
testLogging {
165165
events "PASSED", "FAILED", "SKIPPED"
166166
}

pom.xml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
<plugin>
2424
<groupId>org.apache.maven.plugins</groupId>
2525
<artifactId>maven-compiler-plugin</artifactId>
26+
<version>3.8.1</version>
2627
<configuration>
2728
<source>1.8</source>
2829
<target>1.8</target>
@@ -201,7 +202,7 @@
201202
<configuration>
202203
<systemPropertyVariables>
203204
<environment>remote</environment>
204-
<testtype>single</testtype>
205+
<testType>single</testType>
205206
</systemPropertyVariables>
206207
<properties>
207208
<property>
@@ -229,7 +230,7 @@
229230
<configuration>
230231
<systemPropertyVariables>
231232
<environment>remote</environment>
232-
<testtype>local</testtype>
233+
<testType>local</testType>
233234
</systemPropertyVariables>
234235
<properties>
235236
<property>
@@ -257,7 +258,7 @@
257258
<configuration>
258259
<systemPropertyVariables>
259260
<environment>remote</environment>
260-
<testtype>local</testtype>
261+
<testType>local</testType>
261262
</systemPropertyVariables>
262263
<properties>
263264
<property>
@@ -282,7 +283,7 @@
282283
<configuration>
283284
<systemPropertyVariables>
284285
<environment>remote</environment>
285-
<testtype>local</testtype>
286+
<testType>local</testType>
286287
</systemPropertyVariables>
287288
<properties>
288289
<property>
@@ -311,7 +312,7 @@
311312
<configuration>
312313
<systemPropertyVariables>
313314
<environment>remote</environment>
314-
<testtype>parallel</testtype>
315+
<testType>parallel</testType>
315316
</systemPropertyVariables>
316317
<properties>
317318
<property>
@@ -336,7 +337,7 @@
336337
<configuration>
337338
<systemPropertyVariables>
338339
<environment>remote</environment>
339-
<testtype>parallel</testtype>
340+
<testType>parallel</testType>
340341
</systemPropertyVariables>
341342
<properties>
342343
<property>

src/test/java/com/browserstack/app/pages/Bag.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public void close() {
4242
}
4343

4444
public HomePage waitForItemsInBag(int i) {
45-
waitFortextToBePresentInElement(quantityContainer, Integer.toString(i));
45+
waitForTextToBePresentInElement(quantityContainer, Integer.toString(i));
4646
return new HomePage(driver);
4747
}
4848
}

src/test/java/com/browserstack/app/pages/BasePage.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@ public BasePage(WebDriver driver) {
1616
PageFactory.initElements(driver, this);
1717
}
1818

19-
protected void waitFortextToBePresentInElement(WebElement element, String text) {
19+
protected void waitForElementToBePresent(WebElement element) {
20+
wait.until(ExpectedConditions.visibilityOf(element));
21+
}
22+
23+
protected void waitForTextToBePresentInElement(WebElement element, String text) {
2024
wait.until(ExpectedConditions.textToBePresentInElement(element, text));
2125
}
2226

src/test/java/com/browserstack/app/pages/CheckoutPage.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public CheckoutPage(WebDriver driver) {
2929
}
3030

3131
public ConfirmationPage enterShippingDetails(String firstname, String lastname, String address, String state, String postcode) {
32+
waitForElementToBePresent(firstnameInput);
3233
firstnameInput.sendKeys(firstname);
3334
lastnameInput.sendKeys(lastname);
3435
addressInput.sendKeys(address);

src/test/java/com/browserstack/app/pages/LoginPage.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public LoginPage(WebDriver driver) {
2424
}
2525

2626
public HomePage loginWith(String username, String password) {
27+
waitForElementToBePresent(usernameInput);
2728
usernameInput.sendKeys(username + Keys.ENTER);
2829
passwordInput.sendKeys(password + Keys.ENTER);
2930
logInButton.click();

src/test/java/com/browserstack/test/suites/TestBase.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
public class TestBase {
2828
public static final String PATH_TO_TEST_CAPS_JSON = "src/test/resources/conf/capabilities/test_caps.json";
2929
// ThreadLocal gives the ability to store data individually for the current thread
30-
protected ThreadLocal<WebDriver> driver = new ThreadLocal<>();
30+
private static final ThreadLocal<WebDriver> driver = new ThreadLocal<>();
3131
private static final String DOCKER_SELENIUM_HUB_URL = "http://localhost:4444/wd/hub";
3232
private static final String BROWSERSTACK_HUB_URL = "https://hub.browserstack.com/wd/hub";
3333
private static final long TIMESTAMP = new Date().getTime();
@@ -39,8 +39,8 @@ public WebDriver getDriver() {
3939
}
4040

4141
@BeforeMethod
42-
@Parameters(value = {"environment", "testtype", "env_cap_id"})
43-
public void setUp(@Optional("on-prem") String environment, @Optional("single") String testtype, @Optional("0") int env_cap_id, Method m) throws Exception {
42+
@Parameters(value = {"environment", "testType", "env_cap_id"})
43+
public void setUp(@Optional("on-prem") String environment, @Optional("single") String testType, @Optional("0") int env_cap_id, Method m) throws Exception {
4444
JSONParser parser = new JSONParser();
4545
JSONObject testCapsConfig = (JSONObject) parser.parse(new FileReader(PATH_TO_TEST_CAPS_JSON));
4646
String url = (String) testCapsConfig.get("application_endpoint");
@@ -49,7 +49,7 @@ public void setUp(@Optional("on-prem") String environment, @Optional("single") S
4949
driver.set(new ChromeDriver());
5050
} else if (environment.equalsIgnoreCase("remote")) {
5151
JSONObject profilesJson = (JSONObject) testCapsConfig.get("tests");
52-
JSONObject envs = (JSONObject) profilesJson.get(testtype);
52+
JSONObject envs = (JSONObject) profilesJson.get(testType);
5353

5454
Map<String, String> commonCapabilities = (Map<String, String>) envs.get("common_caps");
5555
commonCapabilities.put("name", m.getName());
@@ -60,7 +60,7 @@ public void setUp(@Optional("on-prem") String environment, @Optional("single") S
6060
DesiredCapabilities caps = new DesiredCapabilities();
6161
caps.merge(new DesiredCapabilities(commonCapabilities));
6262
caps.merge(new DesiredCapabilities(envCapabilities));
63-
if (testtype.equals("local")) {
63+
if (testType.equals("local")) {
6464
url = (String) envs.get("application_endpoint");
6565
caps.merge(new DesiredCapabilities(localCapabilities));
6666
}
@@ -78,13 +78,13 @@ public void setUp(@Optional("on-prem") String environment, @Optional("single") S
7878
driver.set(new RemoteWebDriver(new URL(DOCKER_SELENIUM_HUB_URL), dc));
7979
}
8080
getDriver().get(url);
81-
wait = new WebDriverWait(getDriver(), 25);
82-
getDriver().manage().timeouts().implicitlyWait(25, TimeUnit.SECONDS);
81+
getDriver().manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
82+
wait = new WebDriverWait(getDriver(), 30);
8383
}
8484

8585
@AfterMethod
8686
public void tearDown() throws Exception {
87-
if (driver != null) {
87+
if (getDriver() != null) {
8888
getDriver().quit();
8989
}
9090
if (local != null) {

src/test/java/com/browserstack/test/suites/e2e/OrderTest.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
import com.browserstack.app.pages.HomePage;
55
import com.browserstack.app.pages.OrdersPage;
66
import com.browserstack.test.suites.TestBase;
7+
import org.openqa.selenium.By;
8+
import org.openqa.selenium.support.ui.ExpectedConditions;
79
import org.testng.Assert;
810
import org.testng.annotations.Test;
911

@@ -23,6 +25,7 @@ public void placeOrder() {
2325
Assert.assertTrue(page.isConfirmationDisplayed());
2426

2527
OrdersPage ordersPage = page.continueShopping().navigateToOrders();
28+
wait.until(ExpectedConditions.invisibilityOfElementLocated(By.cssSelector(".spinner")));
2629

2730
Assert.assertEquals(ordersPage.getItemsFromOrder(), 3);
2831
}

src/test/java/com/browserstack/test/suites/login/LoginFailTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@
66
import org.testng.Assert;
77
import org.testng.annotations.Test;
88

9+
910
public class LoginFailTest extends TestBase {
1011

1112
@Test
12-
public void loginSuccess() {
13+
public void loginFail() {
1314
getDriver().findElement(By.id("signin")).click();
1415
getDriver().findElement(By.cssSelector("#username input")).sendKeys("fav_user" + Keys.ENTER);
1516
getDriver().findElement(By.cssSelector("#password input")).sendKeys("testingisfun99" + Keys.ENTER);

src/test/java/com/browserstack/test/suites/offers/OfferTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public void checkOffersInSingapore() {
2727
getDriver().findElement(By.id("login-btn")).click();
2828

2929
getDriver().findElement(By.id("offers")).click();
30-
wait.until(ExpectedConditions.urlContains("offers"));
30+
wait.until(ExpectedConditions.invisibilityOfElementLocated(By.cssSelector(".spinner")));
3131

3232
Assert.assertEquals(getDriver().findElements(By.cssSelector(".offer")).size(), 3);
3333
}

0 commit comments

Comments
 (0)