Skip to content

Commit

Permalink
[java] Improving javadocs for DevTools.java
Browse files Browse the repository at this point in the history
[skip ci]
  • Loading branch information
diemol committed Jul 6, 2022
1 parent ca2f0f9 commit aaa20ba
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions java/src/org/openqa/selenium/devtools/DevTools.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,9 @@ public void createSession() {

/**
* Create CDP session on given window/tab (aka target).
* If windowHandle is null, then _some_ target will be selected. It might be a problem only if you have multiple windows/tabs opened.
* If windowHandle is null, then the first "page" type will be selected.
* Pass the windowHandle if you have multiple windows/tabs opened to connect to
* the expected window/tab.
*
* @param windowHandle result of {@link WebDriver#getWindowHandle()}, optional.
*/
Expand Down Expand Up @@ -139,10 +141,12 @@ public void createSession(String windowHandle) {

private TargetID findTarget(String windowHandle) {
// Figure out the targets.
List<TargetInfo> infos = connection.sendAndWait(cdpSession, getDomains().target().getTargets(), timeout);
List<TargetInfo> infos = connection
.sendAndWait(cdpSession, getDomains().target().getTargets(), timeout);

// Grab the first "page" type, and glom on to that.
// Find out which one might be the current one (using given window handle like "CDwindow-24426957AC62D8BC83E58C184C38AF2D")
// Find out which one might be the current one
// (using given window handle like "CDwindow-24426957AC62D8BC83E58C184C38AF2D")
return infos.stream()
.filter(info -> "page".equals(info.getType()))
.map(TargetInfo::getTargetId)
Expand Down

0 comments on commit aaa20ba

Please sign in to comment.