Skip to content

waitForNavigation() Doesn't Match Playwright Spec #5

@homestar9

Description

@homestar9

I've been testing cbPlaywright with ACF 2018, and I have so much empathy for you, Eric! ACF requires all Java method calls to exactly match the argument signature of the method else it throws a "method not found" error. Lucee is much more forgiving. The ACF limitation makes it more difficult to write fluent Playwright calls.

Anyway, I noticed during testing that calling waitForNavigation() on ACF wasn't working, and I realized that the Playwright docs specify that the method should receive a single 'options' object instead of a 'runnable'. Playwright WaitForNavigation Docs

However, when I dump out the Page object, the method signature doesn't match the Playwright docs:
image

I suspect the Playwright docs are incorrect, and I think the following change to cbPlaywright will fix the issue on ACF engines:

public any function waitForNavigation( required any page, function callback ) {
	if ( isNull( arguments.callback ) ) {
		arguments.callback = function() {};
	}
	var runnable = createDynamicProxy( new Runnable( arguments.callback ), [ "java.lang.Runnable" ] );
	var options = createObject( "java", "com.microsoft.playwright.Page$WaitForNavigationOptions" ).init();  // <-- get options object
	return arguments.page.waitForNavigation( options, runnable ); // <-- add options argument
}

The above change allows waitForNavigation() to work on ACF 💪. However, there is one caveat I have encountered where ACF will throw a null pointer exception if the page URL does not change after a navigation event. The Playwright docs indicate this is normal though:

"In case of navigation to a different anchor or navigation due to History API usage, the navigation will resolve with null."

image

I don't have a good website example right now to help reproduce the issue because I discovered this on a 3rd party website that requires a login. If I can reproduce the issue on a public website, I will follow up on this post with an example.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions