-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #53 from blibli-badak/dev-argo
Support For Charset in HAR Writting
- Loading branch information
Showing
13 changed files
with
158 additions
and
44 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.blibli.oss.qa.util.model; | ||
|
||
public class Constant { | ||
public static String DEFAULT_UNICODE="UTF-8"; | ||
} |
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
4 changes: 2 additions & 2 deletions
4
src/main/java/com/blibli/oss/qa/util/model/RequestResponseStorage.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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.blibli.oss.qa.util; | ||
|
||
import com.blibli.oss.qa.util.services.NetworkListener; | ||
import io.github.bonigarcia.wdm.WebDriverManager; | ||
import org.openqa.selenium.chrome.ChromeDriver; | ||
import org.openqa.selenium.chrome.ChromeOptions; | ||
import org.openqa.selenium.remote.DesiredCapabilities; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.nio.file.Files; | ||
import java.nio.file.Paths; | ||
import java.util.Optional; | ||
|
||
public class BaseTest { | ||
|
||
|
||
|
||
public String readHarData(String fileName) throws IOException { | ||
String harFile = Paths.get(".").toAbsolutePath().normalize().toString() + ""+File.separator +""+fileName; | ||
System.out.println("Read Har Data " + harFile); | ||
return new String(Files.readAllBytes(Paths.get(fileName))); | ||
} | ||
|
||
} | ||
|
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,72 @@ | ||
package com.blibli.oss.qa.util; | ||
|
||
import com.blibli.oss.qa.util.services.NetworkListener; | ||
import io.github.bonigarcia.wdm.WebDriverManager; | ||
import org.junit.jupiter.api.AfterEach; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import org.openqa.selenium.chrome.ChromeDriver; | ||
import org.openqa.selenium.chrome.ChromeOptions; | ||
import org.openqa.selenium.remote.DesiredCapabilities; | ||
|
||
import java.io.IOException; | ||
import java.util.Optional; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
public class UnicodeTest extends BaseTest { | ||
private NetworkListener networkListener; | ||
private static String HAR_UNICODE_NAME = "har-unicode.har"; | ||
private ChromeDriver driver; | ||
private ChromeOptions options; | ||
private DesiredCapabilities capabilities; | ||
|
||
@BeforeEach | ||
public void setup() { | ||
this.setupLocalDriver(); | ||
} | ||
public void setupLocalDriver(){ | ||
options = new ChromeOptions(); | ||
options.addArguments("--no-sandbox"); | ||
options.addArguments("--remote-allow-origins=*"); | ||
options.addArguments("--disable-dev-shm-usage"); | ||
if(Optional.ofNullable(System.getenv("CHROME_MODE")).orElse("").equalsIgnoreCase("headless")){ | ||
options.addArguments("--headless"); | ||
System.out.println("Running With headless mode"); | ||
}else{ | ||
System.out.println("Running Without headless mode"); | ||
} | ||
WebDriverManager.chromedriver().setup(); | ||
} | ||
|
||
|
||
@Test | ||
public void testUnicode() throws InterruptedException, IOException { | ||
driver = new ChromeDriver(options); | ||
driver.manage().window().maximize(); | ||
networkListener = new NetworkListener(driver, driver.getDevTools(), HAR_UNICODE_NAME); | ||
networkListener.setCharset("UTF-8"); | ||
networkListener.start(); | ||
driver.get("https://gosoft.web.id/selenium/unicode.html"); | ||
Thread.sleep(5000); // make sure the web are loaded | ||
driver.quit(); | ||
try { | ||
Thread.sleep(2000); | ||
} catch (InterruptedException e) { | ||
throw new RuntimeException(e); | ||
} | ||
// in the github actions we need add some wait , because chrome exited too slow , | ||
// so when we create new session previous chrome is not closed completly | ||
try { | ||
Thread.sleep(2000); | ||
} catch (InterruptedException e) { | ||
throw new RuntimeException(e); | ||
} | ||
networkListener.createHarFile(); | ||
String harFile = this.readHarData(HAR_UNICODE_NAME); | ||
System.out.println(harFile); | ||
assertTrue(harFile.contains("接口路径不存在 请前往")); | ||
} | ||
|
||
|
||
} |
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