Skip to content

Commit cc65b1f

Browse files
fix(compat): use String charset in URLEncoder.encode for Java 8 [APS-18945] [APS-18946]
- Replace StandardCharsets.UTF_8 (Charset) with "UTF-8" (String) in URLEncoder.encode calls — the Charset overload requires Java 10+ - Add throws Exception to @before setUp methods to satisfy the checked UnsupportedEncodingException declaration - Pre-existing compilation failure on main branch; unrelated to the dependency version bumps in this PR
1 parent 5207295 commit cc65b1f

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

src/test/java/com/browserstack/stepdefs/e2e/StackDemoSteps.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public class StackDemoSteps {
3838
private static final String PRODUCT_IN_CART = "//*[@id=\"__next\"]/div/div/div[2]/div[2]/div[2]/div/div[3]/p[1]";
3939

4040
@Before
41-
public void setUp(Scenario scenario) {
41+
public void setUp(Scenario scenario) throws Exception {
4242
playwright = Playwright.create();
4343
BrowserType browserType = playwright.chromium();
4444

@@ -53,7 +53,7 @@ public void setUp(Scenario scenario) {
5353
caps.put("browser", "chrome");
5454
caps.put("sessionName", scenario.getName());
5555

56-
String encoded = URLEncoder.encode(new JSONObject(caps).toString(), StandardCharsets.UTF_8);
56+
String encoded = URLEncoder.encode(new JSONObject(caps).toString(), "UTF-8");
5757
String wsEndpoint = "wss://cdp.browserstack.com/playwright?caps=" + encoded;
5858

5959
browser = browserType.connect(wsEndpoint);

src/test/java/com/browserstack/stepdefs/local/StackLocalSteps.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public class StackLocalSteps {
2929
private Page page;
3030

3131
@Before
32-
public void setUp(Scenario scenario) {
32+
public void setUp(Scenario scenario) throws Exception {
3333
playwright = Playwright.create();
3434
BrowserType browserType = playwright.chromium();
3535

@@ -45,7 +45,7 @@ public void setUp(Scenario scenario) {
4545
caps.put("browserstack.local", "true");
4646
caps.put("sessionName", scenario.getName());
4747

48-
String encoded = URLEncoder.encode(new JSONObject(caps).toString(), StandardCharsets.UTF_8);
48+
String encoded = URLEncoder.encode(new JSONObject(caps).toString(), "UTF-8");
4949
String wsEndpoint = "wss://cdp.browserstack.com/playwright?caps=" + encoded;
5050

5151
browser = browserType.connect(wsEndpoint);

0 commit comments

Comments
 (0)