Skip to content

Conversation

nithyamn
Copy link
Contributor

Updates in repo:

  1. Modified repo structure
  2. Added support for Junit 5

Junit 4 changes:

  1. Updated browserstack-local version
  2. Added code segment to mark test as passed or failed in BrowserStackJUnitTest class inlined to the docs
  3. Added device combinations to parallel.conf.json

@nithyamn
Copy link
Contributor Author

@francisf - kindly review

public class MarkSessionStatus {
public void markTestStatus(String status, String reason, WebDriver driver){
JavascriptExecutor jse = (JavascriptExecutor) driver;
jse.executeScript("browserstack_executor: {\"action\": \"setSessionStatus\", \"arguments\": {\"status\": \""+ status + "\", \"reason\": \"" + reason + "\"}}");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possible to use a hashmap instead?

{\"action\": \"setSessionStatus\", \"arguments\": {\"status\": \""+ status + "\", \"reason\": \"" + reason + "\"}}"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should I replace the JSE inputs with a hashmap? Need more details on the requirement.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i meant a json object, providing a direct string is making this difficult to read. we can later convert it from object to string

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The syntax used is to keep it simple and inline with our docs.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using REST API instead of JSE


//@WebDriverTest
void googleTest(WebDriver driver) {
driver.get("https://google.com/");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bstack demo?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed to bstackdemo.com

final String product_in_cart = wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//*[@id=\'__next\']/div/div/div[2]/div[2]/div[2]/div/div[3]/p[1]"))).getText();
if (product_name.equals(product_in_cart)) {
sessionStatus.markTestStatus("passed", "Product has been successfully added to the cart!",driver);
}else{
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indentation }else{

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

sessionStatus.markTestStatus("passed", "Local content validated!",driver);
else
sessionStatus.markTestStatus("failed", "Local content not validated!",driver);
}catch (Exception e){
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

space

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

}
accesskey = System.getenv("BROWSERSTACK_ACCESS_KEY");
if(accesskey == null){
accesskey = (String) mainConfig.get("accesskey");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

accessKey = (String) config.get("key"); this was used for sel4, can we keep all the variable names and keys same?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

have modified the variable names to "key" and "user" as per the capabilities doc for Selenium 3

junit-5/pom.xml Outdated
</build>
</profile>
</profiles>
</project>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

eol

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment on lines 23 to +25
{
"browser": "Internet Explorer"
},
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please confirm if bstackdemo works on IE across win versions. Similar issue faced somewhere else

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this works for the test case mentioned in the docs. Here is a session on IE.

@nithyamn nithyamn requested a review from SaranshBS March 29, 2022 09:11
@francisf francisf merged commit a89686f into browserstack:master Mar 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants