Skip to content

Commit

Permalink
Delete manual.yml workflow
Browse files Browse the repository at this point in the history
Update tests
Update README.md
  • Loading branch information
britka committed Apr 18, 2024
1 parent 5e4c1b8 commit 49c0e5e
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 182 deletions.
75 changes: 0 additions & 75 deletions .github/workflows/manual.yml

This file was deleted.

152 changes: 45 additions & 107 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,9 @@ For example:

```java
WebDriver driver = new PlaywrightiumDriver();
driver.

get("https://example.com");
driver.

findElement(By.name("username")).

sendKeys("Some value");
driver.

findElement(By.cssSelector("input[value=submit][name=submitbutton]")).

click();
driver.get("https://example.com");
driver.findElement(By.name("username")).sendKeys("Some value");
driver.findElement(By.cssSelector("input[value=submit][name=submitbutton]")).click();
```

If you need more example please refer to
Expand Down Expand Up @@ -121,11 +111,8 @@ For example:
```java
import org.openqa.selenium.WebElement;

WebElement submitButton =
driver.findElement(PlaywrightiumBy.byRole(AriaRole.BUTTON, AriaRoleOptions.builder().setName("submit").build()));
WebElement driver.

findElement(PlaywrightiumBy.byLabel("LabeText", true));
WebElement submitButton = driver.findElement(PlaywrightiumBy.byRole(AriaRole.BUTTON, AriaRoleOptions.builder().setName("submit").build()));
WebElement driver.findElement(PlaywrightiumBy.byLabel("LabeText", true));
```

### Work with WebElements
Expand All @@ -134,44 +121,29 @@ For example

```java
var name = element.getAttribute("name");
element.

click();
element.

isDisplayed();
element.

getText();
element.click();
element.isDisplayed();
element.getText();
```

### Switch to frame

```java
driver.switchTo().

frame("frameName");
driver.switchTo().frame("frameName");
```

### Works with Select webelement

```java
ISelect select = new PlaywrightiumSelect(driver.findElement(By.name("dropdown")));
select.

selectByValue("dd"+faker.number().

numberBetween(1,7));
select.selectByValue("dd"+faker.number().numberBetween(1,7));
String selectValue = select.getFirstSelectedOption().getAttribute("value");
```

* Use waiters

```java
new WebDriverWait(driver, Duration.ofSeconds(10))
.

until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//h1[contains(.,'Processed Form Details')]")));
new WebDriverWait(driver, Duration.ofSeconds(10)).until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//h1[contains(.,'Processed Form Details')]")));
```

### Use alerts
Expand All @@ -184,36 +156,20 @@ So the example will be
```java
// At first describe what we want to do with alert
Alert alert = driver.switchTo().alert();
alert.

sendKeys(testString);
alert.

accept();
alert.sendKeys(testString);
alert.accept();

// After we do some actions that will lead to alert appearance.
driver.

findElement(By.id("promptexample")).

click();
driver.findElement(By.id("promptexample")).click();

// After we can make some checks
assertThat(alert.getText()).

isEqualTo("I prompt you");
assertThat(alert.getText()).isEqualTo("I prompt you");
```

### Use Actions class

```java
new Actions(driver).

moveToElement(driver.findElement(By.id("someId"))).

build().

perform();
new Actions(driver).moveToElement(driver.findElement(By.id("someId"))).build().perform();
```

> [!IMPORTANT]
Expand All @@ -222,9 +178,7 @@ perform();
### Run JavaScript scripts

```java
((JavascriptExecutor)driver).

executeScript("return alert();");
((JavascriptExecutor)driver).executeScript("return alert();");
```

### Record video
Expand All @@ -233,13 +187,8 @@ Initialize Playwrightium driver using `PlaywrightiumOptions` class

```java
PlaywrightiumOptions playwrightiumOptions = new PlaywrightiumOptions();
playwrightiumOptions.

setRecordVideo(true);

driver =new

PlaywrightiumDriver(playwrightiumOptions);
playwrightiumOptions.setRecordVideo(true);
driver = new PlaywrightiumDriver(playwrightiumOptions);
```

> [!IMPORTANT]
Expand All @@ -249,15 +198,9 @@ or to initialize records folder

```java
PlaywrightiumOptions playwrightiumOptions = new PlaywrightiumOptions();
playwrightiumOptions.

setRecordVideo(true);
playwrightiumOptions.

setRecordsFolder(Path.of("videosFolder"));
driver =new

PlaywrightiumDriver(playwrightiumOptions);
playwrightiumOptions.setRecordVideo(true);
playwrightiumOptions.setRecordsFolder(Path.of("videosFolder"));
driver = new PlaywrightiumDriver(playwrightiumOptions);
```

> [!IMPORTANT]
Expand Down Expand Up @@ -296,15 +239,9 @@ Initialize Playwrightium driver using `PlaywrightiumOptions` class

```java
PlaywrightiumOptions playwrightiumOptions = new PlaywrightiumOptions();
playwrightiumOptions.

setConnectionByWS(false);
playwrightiumOptions.

setHeadless(true);
return new

PlaywrightiumDriver("http://localhost:4444/wd/hub",chromeOptions);
playwrightiumOptions.setConnectionByWS(false);
playwrightiumOptions.setHeadless(true);
return new PlaywrightiumDriver("http://localhost:4444/wd/hub",chromeOptions);
```

> [!IMPORTANT]
Expand All @@ -320,15 +257,9 @@ Initialize Playwrightium driver using `PlaywrightiumOptions` class

```java
PlaywrightiumOptions playwrightiumOptions = new PlaywrightiumOptions();
playwrightiumOptions.

setConnectionByWS(true);
playwrightiumOptions.

setHeadless(true);
return new

PlaywrightiumDriver("http://localhost:4444/wd/hub",playwrightiumOptions);
playwrightiumOptions.setConnectionByWS(true);
playwrightiumOptions.setHeadless(true);
return new PlaywrightiumDriver("http://localhost:4444/wd/hub",playwrightiumOptions);
```

> [!IMPORTANT]
Expand Down Expand Up @@ -356,20 +287,27 @@ Then you should use it with `Configuration`
E.g.

```java
Configuration.browser =PWDriverProvider .class.

getName();
Configuration.browser = PWDriverProvider.class.getName();
```

## Playwrightium options

| Option name | Type | Description |
|----------------|---------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| headless | boolean | Run tests in "headless" node or not |
| browserName | string | What browser to run. Available values: chromium, firefox, webkit |
| recordVideo | boolean | Indicates will the video be recorded or not |
| recordsFolder | string | The folder where video recordings will be saved. Default {project.basedir}/build/video |
| connectionByWS | boolean | Indicates how we will run tests remotelly. If we will use Selenoid/Selenium grid then we should choose false (works for chrome only), if we will use Moon then we should choose true |
| Option name | Type | Description |
|----------------|----------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| headless | boolean | Run tests in "headless" node or not |
| browserName | string | What browser to run. Available values: chromium, firefox, webkit |
| recordVideo | boolean | Indicates will the video be recorded or not |
| recordsFolder | string | The folder where video recordings will be saved. Default {project.basedir}/build/video |
| connectionByWS | boolean | Indicates how we will run tests remotelly. If we will use Selenoid/Selenium grid then we should choose false (works for chrome only), if we will use Moon then we should choose true |
| emulation | [Device](src/main/java/org/brit/emulation/Device.java) | Emulates the device |
| locale | [Locale](https://docs.oracle.com/javase/8/docs/api/java/util/Locale.html) | Emulates locale |
| timeZone | [TimeZone](https://docs.oracle.com/javase/8/docs/api/java/util/TimeZone.html) | Emulates timezone |
| geolocation | [Geolocation](https://www.javadoc.io/doc/com.microsoft.playwright/playwright/latest/com/microsoft/playwright/options/Geolocation.html) | Emulates geolocation |
| permissions | List<[Permissions](src/main/java/org/brit/permission/Permissions.java)> | Switch on permissions |

> [!IMPORTANT]
> For now all this options might be set only by [PlaywrightiumOptions](src/main/java/org/brit/options/PlaywrightiumOptions.java)

And that's all. You can easily use it with Selenide.
See [test for Selenide](src/test/java/org/brit/test/selenide/)
Expand Down

0 comments on commit 49c0e5e

Please sign in to comment.