Package io.karatelabs.driver.w3c
Class W3cSession
java.lang.Object
io.karatelabs.driver.w3c.W3cSession
W3C WebDriver HTTP session client.
Uses java.net.http.HttpClient for clean separation from scenario HTTP state.
Implements the W3C WebDriver protocol: W3C WebDriver Specification
-
Method Summary
Modifier and TypeMethodDescriptionvoidvoidvoidback()voidclearElement(String elementId) voidclickElement(String elementId) voidstatic W3cSessionCreate a new WebDriver session.voidvoiddeleteCookie(String name) voidvoidbyte[]elementScreenshot(String elementId) executeScript(String script, Object... args) findElement(String using, String value) Find a single element.findElements(String using, String value) Find multiple elements.voidforward()voidgetElementAttribute(String elementId, String name) getElementProperty(String elementId, String name) getElementTagName(String elementId) getElementText(String elementId) getTitle()getUrl()booleanisElementEnabled(String elementId) voidvoidvoidnavigateTo(String url) voidvoidperformActions(List<Map<String, Object>> actions) Perform W3C Actions (keyboard, mouse, pointer).voidrefresh()voidRelease all actions (reset keyboard/mouse state).byte[]voidsendAlertText(String text) voidvoidsetWindowRect(Map<String, Object> rect) voidswitchFrame(Object id) voidswitchWindow(String handle)
-
Method Details
-
create
public static W3cSession create(String baseUrl, Map<String, Object> sessionPayload, Duration timeout) Create a new WebDriver session.- Parameters:
baseUrl- WebDriver server URL (e.g., "http://localhost:9515")sessionPayload- W3C session creation payloadtimeout- request timeout- Returns:
- a new W3cSession
-
getUrl
-
getTitle
-
back
public void back() -
forward
public void forward() -
refresh
public void refresh() -
executeScript
-
findElement
Find a single element. Returns the W3C element ID.- Throws:
DriverException- if element not found
-
findElements
Find multiple elements. Returns list of W3C element IDs. -
clickElement
-
sendKeys
-
clearElement
-
getElementText
-
getElementAttribute
-
getElementProperty
-
getElementTagName
-
isElementEnabled
-
elementScreenshot
-
screenshot
public byte[] screenshot() -
switchFrame
-
parentFrame
public void parentFrame() -
getAlertText
-
acceptAlert
public void acceptAlert() -
dismissAlert
public void dismissAlert() -
sendAlertText
-
getWindowRect
-
setWindowRect
-
maximizeWindow
public void maximizeWindow() -
minimizeWindow
public void minimizeWindow() -
fullscreenWindow
public void fullscreenWindow() -
getWindowHandle
-
getWindowHandles
-
switchWindow
-
closeWindow
public void closeWindow() -
getCookie
-
getAllCookies
-
addCookie
-
deleteCookie
-
deleteAllCookies
public void deleteAllCookies() -
performActions
Perform W3C Actions (keyboard, mouse, pointer). POST /session/{id}/actions -
releaseActions
public void releaseActions()Release all actions (reset keyboard/mouse state). DELETE /session/{id}/actions -
deleteSession
public void deleteSession() -
getSessionId
-