Skip to content

Commit bbd5152

Browse files
committed
improve java api docs for driver
1 parent 4db11f0 commit bbd5152

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

karate-core/README.md

+18-3
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@
153153
<tr>
154154
<th>Chrome</th>
155155
<td>
156-
<a href="#chrome-java-api">Java API</a>
156+
<a href="#java-api">Java API</a>
157157
| <a href="#driverpdf"><code>driver.pdf()</code></a>
158158
| <a href="#driverscreenshotfull"><code>driver.screenshotFull()</code></a>
159159
| <a href="#driverintercept"><code>driver.intercept()</code></a>
@@ -1879,8 +1879,23 @@ In real-life flows, you may need to pass cookies from the [browser](#cookie) to
18791879

18801880
A video of the above execution can be viewed [here](https://twitter.com/ptrthomas/status/1253373486384295936).
18811881

1882-
# Chrome Java API
1883-
Karate also has a Java API to automate the Chrome browser directly, designed for common needs such as converting HTML to PDF - or taking a screenshot of a page. Here is an [example](../karate-demo/src/test/java/driver/screenshot/ChromePdfRunner.java):
1882+
# Java API
1883+
## Driver Java API
1884+
You can start a [`Driver`]() instance programmatically and perform actions and assertions like this:
1885+
1886+
```java
1887+
Driver driver = Driver.start("chrome");
1888+
driver.setUrl(serverUrl + "/05");
1889+
driver.click("button");
1890+
driver.waitForText("#containerDiv", "hello world");
1891+
```
1892+
1893+
You can find the complete example [here](../karate-e2e-tests/src/test/java/driver/JavaApiRunner.java). Also see this [explanation](https://twitter.com/KarateDSL/status/1353969718730788865).
1894+
1895+
Also see the [Karate Java API](https://github.com/intuit/karate#java-api).
1896+
1897+
## Chrome Java API
1898+
As a convenience you can use the [`Chrome`](../karate-core/src/main/java/com/intuit/karate/driver/chrome/Chrome.java) concrete implementation of a `Driver` directly, designed for common needs such as converting HTML to PDF - or taking a screenshot of a page. Here is an [example](../karate-demo/src/test/java/driver/screenshot/ChromePdfRunner.java):
18841899

18851900
```java
18861901
import com.intuit.karate.FileUtils;

0 commit comments

Comments
 (0)