@@ -262,21 +262,32 @@ public Task<ElementHandle> WaitForXPathAsync(string xpath, WaitForSelectorOption
262262 public Task WaitForTimeoutAsync ( int milliseconds ) => Task . Delay ( milliseconds ) ;
263263
264264 /// <summary>
265- /// Waits for a script to be evaluated to a truthy value
265+ /// Waits for a function to be evaluated to a truthy value
266266 /// </summary>
267267 /// <param name="script">Function to be evaluated in browser context</param>
268268 /// <param name="options">Optional waiting parameters</param>
269269 /// <param name="args">Arguments to pass to <c>script</c></param>
270270 /// <returns>A task that resolves when the <c>script</c> returns a truthy value</returns>
271271 /// <seealso cref="Page.WaitForFunctionAsync(string, WaitForFunctionOptions, object[])"/>
272272 public Task < JSHandle > WaitForFunctionAsync ( string script , WaitForFunctionOptions options , params object [ ] args )
273- => new WaitTask ( this , script , options . Polling , options . PollingInterval , options . Timeout , args ) . Task ;
273+ => new WaitTask ( this , script , false , "function" , options . Polling , options . PollingInterval , options . Timeout , args ) . Task ;
274+
275+ /// <summary>
276+ /// Waits for an expression to be evaluated to a truthy value
277+ /// </summary>
278+ /// <param name="script">Expression to be evaluated in browser context</param>
279+ /// <param name="options">Optional waiting parameters</param>
280+ /// <param name="args">Arguments to pass to <c>script</c></param>
281+ /// <returns>A task that resolves when the <c>script</c> returns a truthy value</returns>
282+ /// <seealso cref="Page.WaitForExpressionAsync(string, WaitForFunctionOptions)"/>
283+ public Task < JSHandle > WaitForExpressionAsync ( string script , WaitForFunctionOptions options )
284+ => new WaitTask ( this , script , true , "function" , options . Polling , options . PollingInterval , options . Timeout ) . Task ;
274285
275286 /// <summary>
276287 /// Triggers a change and input event once all the provided options have been selected.
277288 /// If there's no <![CDATA[<select>]]> element matching selector, the method throws an error.
278289 /// </summary>
279- /// <exception cref="SelectorException">If there's no element matching <paramref name="selector"/></exception>
290+ /// <exception cref="SelectorException">If there's no element matching <paramref name="selector"/></exception>
280291 /// <param name="selector">A selector to query page for</param>
281292 /// <param name="values">Values of options to select. If the <![CDATA[<select>]]> has the multiple attribute,
282293 /// all values are considered, otherwise only the first one is taken into account.</param>
@@ -522,11 +533,21 @@ function hasVisibleBoundingBox() {
522533 }
523534 }" ;
524535 var polling = options . Visible || options . Hidden ? WaitForFunctionPollingOption . Raf : WaitForFunctionPollingOption . Mutation ;
525- var handle = await WaitForFunctionAsync ( predicate , new WaitForFunctionOptions
526- {
527- Timeout = options . Timeout ,
528- Polling = polling
529- } , selectorOrXPath , isXPath , options . Visible , options . Hidden ) ;
536+ var handle = await new WaitTask (
537+ this ,
538+ predicate ,
539+ false ,
540+ $ "{ ( isXPath ? "XPath" : "selector" ) } '{ selectorOrXPath } '",
541+ options . Polling ,
542+ options . PollingInterval ,
543+ options . Timeout ,
544+ new object [ ]
545+ {
546+ selectorOrXPath ,
547+ isXPath ,
548+ options . Visible ,
549+ options . Hidden
550+ } ) . Task ;
530551 return handle as ElementHandle ;
531552 }
532553
0 commit comments