Skip to content

Commit

Permalink
2.2
Browse files Browse the repository at this point in the history
PlaywrightWindow:
- Fixed click
  • Loading branch information
Osiris-Team committed Oct 15, 2021
1 parent 3221a3a commit f90af9a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.osiris.headlessbrowser</groupId>
<artifactId>Headless-Browser</artifactId>
<version>2.1</version>
<version>2.2</version>
<repositories>
<repository>
<id>jitpack</id>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -596,8 +596,8 @@ public PlaywrightWindow middleClick(String selector) throws NodeJsCodeException
* See {@link #click(String, String, int, int)} for details.
*/
public PlaywrightWindow click(String selector, String type) throws NodeJsCodeException {
int max = 1000;
int min = 200;
int max = 200;
int min = 50;
return click(selector, type, 1, new Random().nextInt(max + 1 - min) + min);
}

Expand All @@ -612,12 +612,8 @@ public PlaywrightWindow click(String selector, String type) throws NodeJsCodeExc
* @param delay the time to wait between mousedown and mouseup in milliseconds.
*/
public PlaywrightWindow click(String selector, String type, int clickCount, int delay) throws NodeJsCodeException {
jsContext.executeJavaScript("var options = {\n" +
"button: '" + type + "',\n" +
"clickCount: " + clickCount + ",\n" +
"delay: " + delay + "\n" +
"}\n" +
"await page.click(" + selector + ", options);\n");
jsContext.executeJavaScript(""+
"await page.click('" + selector + "', {button: '"+type+"', clickCount: "+clickCount+", delay:"+delay+"});\n");
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,18 @@ void fullTest() throws Exception {
HBrowser hBrowser = new HBrowser();
try (PlaywrightWindow window = hBrowser.openCustomWindow().debugOutputStream(System.out).headless(false).buildPlaywrightWindow()) {
window.load(new File(System.getProperty("user.dir") + "/test.html"));
formFillingTest(window);
window.load("example.com");
System.out.println(window.getResponseHeaders().toString());
clickTest(window);
Thread.sleep(30000);
//formFillingTest(window);
//window.load("example.com");
//System.out.println(window.getResponseHeaders().toString());
}
}

private void clickTest(PlaywrightWindow window) throws NodeJsCodeException {
window.leftClick("a[href=\"#text\"]");
}

private void formFillingTest(PlaywrightWindow window) throws NodeJsCodeException, InterruptedException {
String expected = "This is the expected value!";
String actual = null;
Expand Down

0 comments on commit f90af9a

Please sign in to comment.