Skip to content

Commit

Permalink
user assertJ library for asserting in the BrowserStackImageInjectionTest
Browse files Browse the repository at this point in the history
  • Loading branch information
anandbagmar committed Mar 10, 2023
1 parent 7e7171a commit fd500cb
Showing 1 changed file with 12 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.testng.AssertJUnit;

import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;

import static org.assertj.core.api.Assertions.assertThat;

class BrowserStackImageInjectionTest {
private static final String LOG_DIR = "./target/testLogs";

Expand All @@ -24,7 +25,7 @@ class BrowserStackImageInjectionTest {
static String cloudName = null;

@BeforeAll
public static void getSetup() {
static void getSetup() {
System.setProperty("LOG_DIR", LOG_DIR);
new File(LOG_DIR).mkdirs();

Expand All @@ -38,22 +39,23 @@ public static void getSetup() {
caps.setCapability("browserstack.enableCameraImageInjection", "true");
try {
driver = new AndroidDriver(
new URL("https://" + authenticationUser + ":" + authenticationKey + "@hub" +
"-cloud.browserstack.com/wd/hub"),
caps);
new URL(String.format("https://%s:%s@hub-cloud.browserstack.com/wd/hub",
authenticationUser, authenticationKey)), caps);

} catch(MalformedURLException e) {
throw new RuntimeException(e.getMessage());
throw new RuntimeException(
String.format("Error starting Android driver: %s", e.getMessage()), e);
}
}

// @Test
public void toVerifyUploadURLIsGettingGenerated() {
void toVerifyUploadURLIsGettingGenerated() {
String imageFile = System.getProperty(
"user.dir") + "/src/test/resources/images/handbag.jpg";
AssertJUnit.assertNotNull(BrowserStackImageInjection.injectMediaToDriver(imageFile, driver,
authenticationUser,
authenticationKey));
assertThat(BrowserStackImageInjection.injectMediaToDriver(imageFile, driver,
authenticationUser,
authenticationKey)).as(
"Injecting image to device failed").isNotNull();
}

}

0 comments on commit fd500cb

Please sign in to comment.