-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed BrowserStack execution for mobile-web (added sample test to run…
… chrome browser test in real android device in BS)
- Loading branch information
1 parent
93a254b
commit 1e90fa6
Showing
9 changed files
with
174 additions
and
7 deletions.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
caps/googlesearch/googlesearch_browserstack_android_emulator_chrome.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
{ | ||
"web": { | ||
"browserName":"chrome", | ||
"browserstackOptions": { | ||
"deviceName": "Samsung Galaxy S20", | ||
"osVersion": "13.0", | ||
"projectName": "ab", | ||
"buildName": "fff", | ||
"sessionName": "test", | ||
"appiumVersion": "2.0.1", | ||
"local": "false", | ||
"networkLogs": "true", | ||
"consoleLogs": "info", | ||
"geoLocation": "IN", | ||
"timezone": "Kolkata" | ||
} | ||
}, | ||
"serverConfig" : { | ||
"server": { | ||
"use-plugins": ["device-farm"], | ||
"plugin": { | ||
"device-farm": { | ||
"platform": "web", | ||
"skipChromeDownload": true, | ||
"cloud": { | ||
"cloudName": "browserstack", | ||
"url": "http://hub-cloud.browserstack.com", | ||
"apiUrl": "https://api-cloud.browserstack.com/app-automate/", | ||
"devices": [ | ||
], | ||
"web": {} | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"appiumServerPath": "./node_modules/appium/build/lib/main.js" | ||
} |
30 changes: 30 additions & 0 deletions
30
configs/googlesearch/googlesearch_browserstack_android_chrome_config.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
RUNNER=distribute | ||
FRAMEWORK=cucumber | ||
RUNNER_LEVEL=methods | ||
CAPS=./caps/googlesearch/googlesearch_browserstack_android_emulator_chrome.json | ||
APP_NAME=Google_Chrome | ||
APP_PACKAGE_NAME=com.chrome.conferences | ||
APPLITOOLS_CONFIGURATION=./configs/applitools_config.json | ||
BASE_URL_FOR_WEB=TESWIZ_BASE_URL | ||
BROWSER=chrome | ||
CLOUD_USERNAME=username | ||
CLOUD_KEY=key | ||
CLOUD_UPLOAD_APP=false | ||
CLOUD_NAME=browserstack | ||
CLOUD_USE_PROXY=false | ||
CLOUD_USE_LOCAL_TESTING=false | ||
ENVIRONMENT_CONFIG_FILE=./src/test/resources/environments.json | ||
IS_VISUAL=true | ||
FAIL_TEST_ON_VISUAL_DIFFERENCE=true | ||
LOG_DIR=target | ||
LOG_PROPERTIES_FILE=./src/test/resources/log4j.properties | ||
PARALLEL=1 | ||
PLATFORM=android | ||
PROXY_KEY=HTTP_PROXY | ||
REPORT_PORTAL_FILE=src/test/resources/reportportal.properties | ||
RP_DESCRIPTION=custom description | ||
RUN_IN_CI=true | ||
TARGET_ENVIRONMENT=prod | ||
LAUNCH_NAME_SUFFIX= on 'prod' Environment | ||
TEST_DATA_FILE=./src/test/resources/testData.json | ||
BROWSER_CONFIG_FILE=./configs/browser_config.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
src/test/java/com/znsio/teswiz/screen/web/googlesearch/GoogleSearchLandingScreenWeb.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package com.znsio.teswiz.screen.web.googlesearch; | ||
|
||
import com.context.TestExecutionContext; | ||
import com.znsio.teswiz.runner.Driver; | ||
import com.znsio.teswiz.runner.Runner; | ||
import com.znsio.teswiz.runner.Visual; | ||
import com.znsio.teswiz.screen.googlesearch.GoogleSearchLandingScreen; | ||
import com.znsio.teswiz.screen.googlesearch.GoogleSearchResultsScreen; | ||
import org.apache.log4j.Logger; | ||
import org.openqa.selenium.By; | ||
import org.openqa.selenium.Keys; | ||
|
||
public class GoogleSearchLandingScreenWeb extends GoogleSearchLandingScreen { | ||
private static final String URL = "https://google.com"; | ||
private static final String SCREEN_NAME = GoogleSearchLandingScreenWeb.class.getSimpleName(); | ||
private static final Logger LOGGER = Logger.getLogger(SCREEN_NAME); | ||
private static final By SEARCH_INPUT = By.name("q"); | ||
|
||
private final Driver driver; | ||
private final Visual visually; | ||
private final TestExecutionContext context; | ||
|
||
public GoogleSearchLandingScreenWeb(Driver driver, Visual visually) { | ||
this.driver = driver; | ||
this.visually = visually; | ||
long threadId = Thread.currentThread().getId(); | ||
context = Runner.getTestExecutionContext(threadId); | ||
driver.getInnerDriver().get(URL); | ||
driver.waitTillElementIsPresent(SEARCH_INPUT); | ||
} | ||
|
||
@Override | ||
public GoogleSearchResultsScreen searchFor(String searchText) { | ||
visually.checkWindow(SCREEN_NAME, "Google"); | ||
driver.findElement(SEARCH_INPUT).sendKeys(searchText, Keys.ENTER); | ||
return GoogleSearchResultsScreen.get(); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
src/test/java/com/znsio/teswiz/screen/web/googlesearch/GoogleSearchResultsScreenWeb.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package com.znsio.teswiz.screen.web.googlesearch; | ||
|
||
import com.context.TestExecutionContext; | ||
import com.znsio.teswiz.runner.Driver; | ||
import com.znsio.teswiz.runner.Runner; | ||
import com.znsio.teswiz.runner.Visual; | ||
import com.znsio.teswiz.screen.googlesearch.GoogleSearchResultsScreen; | ||
import org.apache.log4j.Logger; | ||
import org.openqa.selenium.By; | ||
|
||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
public class GoogleSearchResultsScreenWeb extends GoogleSearchResultsScreen { | ||
private static final String SCREEN_NAME = GoogleSearchResultsScreenWeb.class.getSimpleName(); | ||
private static final Logger LOGGER = Logger.getLogger(SCREEN_NAME); | ||
private final Driver driver; | ||
private final Visual visually; | ||
private final TestExecutionContext context; | ||
|
||
private final By searchResultsHeadings = By.cssSelector("a div[role='heading']"); | ||
|
||
public GoogleSearchResultsScreenWeb(Driver driver, Visual visually) { | ||
this.driver = driver; | ||
this.visually = visually; | ||
long threadId = Thread.currentThread().getId(); | ||
context = Runner.getTestExecutionContext(threadId); | ||
} | ||
|
||
@Override | ||
public List<String> getSearchResults() { | ||
visually.checkWindow(SCREEN_NAME, "india - Google Search"); | ||
return driver.findElements(searchResultsHeadings).stream().map(webElement -> webElement.getText()).collect(Collectors.toList()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters