Skip to content

Commit

Permalink
Add Browserstack Test
Browse files Browse the repository at this point in the history
  • Loading branch information
bijan2007 committed May 30, 2020
1 parent 4a92980 commit edd05e8
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 7 deletions.
29 changes: 28 additions & 1 deletion src/test/java/com/qascript/StepDefs.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,20 @@

import io.cucumber.java.en.Given;
import io.cucumber.java.en.Then;
import org.junit.After;
import org.junit.Assert;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;

import java.net.MalformedURLException;
import java.net.URL;

public class StepDefs {
WebDriver driver;
String username = System.getenv("BROWSERSTACK_USERNAME");
String accessKey = System.getenv("BROWSERSTACK_ACCESS_KEY");
String URL = "https://" + username + ":" + accessKey + "@hub-cloud.browserstack.com/wd/hub";

@Given("Launch website")
public void launchQAScript() {
Expand All @@ -26,4 +33,24 @@ public void qascriptPageIsDisplayedToUser() {
Assert.assertEquals(strTitle, "SeleniumHQ Browser Automation");
driver.quit();
}

@Given("Launch website in BS")
public void launchWebsiteInBS() {
DesiredCapabilities caps = new DesiredCapabilities();
caps.setCapability("os", "Windows");
caps.setCapability("os_version", "10");
caps.setCapability("browser", "Chrome");
caps.setCapability("browser_version", "80");
caps.setCapability("name", "qascript1's First Test");
try {
WebDriver bs_driver = new RemoteWebDriver(new URL(URL), caps);
bs_driver.get("https://www.selenium.dev/");
String strTitle = bs_driver.getTitle();
Assert.assertEquals(strTitle, "SeleniumHQ Browser Automation");
bs_driver.quit();
} catch (MalformedURLException e) {
e.printStackTrace();
}

}
}
6 changes: 6 additions & 0 deletions src/test/resources/features/Test.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Feature: Browserstack Tests

Scenario: Run tests in Browserstack

Given Launch website
Then Website is displayed to user
5 changes: 5 additions & 0 deletions src/test/resources/features/browserstackTest.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Feature: Launch

Scenario: Verify user can launch webpage

Given Launch website in BS
6 changes: 0 additions & 6 deletions src/test/resources/features/test.feature

This file was deleted.

0 comments on commit edd05e8

Please sign in to comment.