Package com.microsoft.playwright.impl
Class WorkerImpl
- java.lang.Object
-
- com.microsoft.playwright.impl.LoggingSupport
-
- com.microsoft.playwright.impl.ChannelOwner
-
- com.microsoft.playwright.impl.WorkerImpl
-
- All Implemented Interfaces:
Worker
class WorkerImpl extends ChannelOwner implements Worker
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static classWorkerImpl.EventType-
Nested classes/interfaces inherited from interface com.microsoft.playwright.Worker
Worker.WaitForCloseOptions
-
-
Field Summary
Fields Modifier and Type Field Description private ListenerCollection<WorkerImpl.EventType>listeners(package private) PageImplpage-
Fields inherited from class com.microsoft.playwright.impl.ChannelOwner
connection, guid, initializer, type
-
-
Constructor Summary
Constructors Constructor Description WorkerImpl(ChannelOwner parent, java.lang.String type, java.lang.String guid, com.google.gson.JsonObject initializer)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Objectevaluate(java.lang.String pageFunction, java.lang.Object arg)Returns the return value ofexpression.JSHandleevaluateHandle(java.lang.String pageFunction, java.lang.Object arg)Returns the return value ofexpressionas aJSHandle.protected voidhandleEvent(java.lang.String event, com.google.gson.JsonObject params)voidoffClose(java.util.function.Consumer<Worker> handler)Removes handler that was previously added withonClose(handler).voidonClose(java.util.function.Consumer<Worker> handler)Emitted when this dedicated WebWorker is terminated.java.lang.Stringurl()WorkerwaitForClose(Worker.WaitForCloseOptions options, java.lang.Runnable code)Performs action and waits for the Worker to close.private WorkerwaitForCloseImpl(Worker.WaitForCloseOptions options, java.lang.Runnable code)private <T> TwaitForEventWithTimeout(WorkerImpl.EventType eventType, java.lang.Runnable code, java.lang.Double timeout)-
Methods inherited from class com.microsoft.playwright.impl.ChannelOwner
adopt, disposeChannelOwner, runUntil, sendMessage, sendMessage, sendMessageAsync, toProtocolRef, withLogging, withWaitLogging
-
Methods inherited from class com.microsoft.playwright.impl.LoggingSupport
logApi, logApiIfEnabled, logWithTimestamp, withLogging
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.microsoft.playwright.Worker
evaluate, evaluateHandle, waitForClose
-
-
-
-
Field Detail
-
listeners
private final ListenerCollection<WorkerImpl.EventType> listeners
-
page
PageImpl page
-
-
Constructor Detail
-
WorkerImpl
WorkerImpl(ChannelOwner parent, java.lang.String type, java.lang.String guid, com.google.gson.JsonObject initializer)
-
-
Method Detail
-
onClose
public void onClose(java.util.function.Consumer<Worker> handler)
Description copied from interface:WorkerEmitted when this dedicated WebWorker is terminated.
-
offClose
public void offClose(java.util.function.Consumer<Worker> handler)
Description copied from interface:WorkerRemoves handler that was previously added withonClose(handler).
-
waitForEventWithTimeout
private <T> T waitForEventWithTimeout(WorkerImpl.EventType eventType, java.lang.Runnable code, java.lang.Double timeout)
-
waitForClose
public Worker waitForClose(Worker.WaitForCloseOptions options, java.lang.Runnable code)
Description copied from interface:WorkerPerforms action and waits for the Worker to close.- Specified by:
waitForClosein interfaceWorkercode- Callback that performs the action triggering the event.
-
waitForCloseImpl
private Worker waitForCloseImpl(Worker.WaitForCloseOptions options, java.lang.Runnable code)
-
evaluate
public java.lang.Object evaluate(java.lang.String pageFunction, java.lang.Object arg)Description copied from interface:WorkerReturns the return value ofexpression.If the function passed to the
Worker.evaluate()returns a Promise, thenWorker.evaluate()would wait for the promise to resolve and return its value.If the function passed to the
Worker.evaluate()returns a non-[Serializable] value, thenWorker.evaluate()returnsundefined. Playwright also supports transferring some additional values that are not serializable byJSON:-0,NaN,Infinity,-Infinity.
-
evaluateHandle
public JSHandle evaluateHandle(java.lang.String pageFunction, java.lang.Object arg)
Description copied from interface:WorkerReturns the return value ofexpressionas aJSHandle.The only difference between
Worker.evaluate()andWorker.evaluateHandle()is thatWorker.evaluateHandle()returnsJSHandle.If the function passed to the
Worker.evaluateHandle()returns a Promise, thenWorker.evaluateHandle()would wait for the promise to resolve and return its value.- Specified by:
evaluateHandlein interfaceWorker- Parameters:
pageFunction- JavaScript expression to be evaluated in the browser context. If the expression evaluates to a function, the function is automatically invoked.arg- Optional argument to pass toexpression.
-
handleEvent
protected void handleEvent(java.lang.String event, com.google.gson.JsonObject params)- Overrides:
handleEventin classChannelOwner
-
-