Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Video does not record everything #510

Closed
qwpnqjucz opened this issue Jul 6, 2021 · 6 comments
Closed

Video does not record everything #510

qwpnqjucz opened this issue Jul 6, 2021 · 6 comments

Comments

@qwpnqjucz
Copy link

qwpnqjucz commented Jul 6, 2021

Similar to #432 this bug still exists in v1.12.1.

I've added a more complete example below. The video does not show the second click page.click("a:text('Docker')");. However if you change page.waitForSelector("#thisShouldMakeTestFail", new Page.WaitForSelectorOptions().setTimeout(1)) to a larger timeout like page.waitForSelector("#thisShouldMakeTestFail", new Page.WaitForSelectorOptions().setTimeout(1000)) the video will show clicking on the Docker link.

I noticed in #432 that acomment was made that The problem happens when the page is explicitly closed,. I don't think this is the case because even if your remove the explicit page.close you get the same issue.

package org.example;

import com.microsoft.playwright.*;

import java.nio.file.Paths;

public class PlaywrightTest {
    public static void main(String[] args) {
        Playwright playwright = null;
        Browser browser = null;
        BrowserContext context = null;
        Page page = null;

        try {
            playwright = Playwright.create();
            var launchOptions = new BrowserType.LaunchOptions();
            launchOptions
                    .setHeadless(false);
            browser = playwright.chromium().launch(launchOptions);
            var videoPath = Paths.get("videos/");

            var contextOptions = new Browser.NewContextOptions()
                    .setViewportSize(1920, 1080)
                    .setRecordVideoDir(videoPath)
                    .setRecordVideoSize(1920,1080);

            context = browser.newContext(contextOptions);
            page = context.newPage();
            page.navigate("https://playwright.dev/java/");
            page.click("a:text('Get started')");
            page.click("a:text('Docker')");
            page.waitForSelector("#thisShouldMakeTestFail", new Page.WaitForSelectorOptions().setTimeout(1));
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
           //  page.close();
            context.close();
            browser.close();
            playwright.close();
        }
    }
}

my pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>org.example</groupId>
    <artifactId>playwright-test</artifactId>
    <version>1.0-SNAPSHOT</version>

    <properties>
        <maven.compiler.source>13</maven.compiler.source>
        <maven.compiler.target>13</maven.compiler.target>
    </properties>

    <dependencies>
        <dependency>
            <groupId>com.microsoft.playwright</groupId>
            <artifactId>playwright</artifactId>
            <version>1.12.1</version>
        </dependency>
    </dependencies>

</project>
@qwpnqjucz
Copy link
Author

Here are the logs which show that the docker link was clicked but the video does not show that click happening:

C:\Users\qwpnqjucz\.jdks\azul-13.0.6\bin\java.exe "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA 2021.1\lib\idea_rt.jar=61456:C:\Program Files\JetBrains\IntelliJ IDEA 2021.1\bin" -Dfile.encoding=UTF-8 -classpath C:\Users\qwpnqjucz\dev\playwright-test\target\classes;C:\Users\qwpnqjucz\.m2\repository\com\microsoft\playwright\playwright\1.12.1\playwright-1.12.1.jar;C:\Users\qwpnqjucz\.m2\repository\com\google\code\gson\gson\2.8.6\gson-2.8.6.jar;C:\Users\qwpnqjucz\.m2\repository\org\java-websocket\Java-WebSocket\1.5.1\Java-WebSocket-1.5.1.jar;C:\Users\qwpnqjucz\.m2\repository\org\slf4j\slf4j-api\1.7.25\slf4j-api-1.7.25.jar;C:\Users\qwpnqjucz\.m2\repository\com\microsoft\playwright\driver\1.12.1\driver-1.12.1.jar;C:\Users\qwpnqjucz\.m2\repository\com\microsoft\playwright\driver-bundle\1.12.1\driver-bundle-1.12.1.jar org.example.PlaywrightTest
2021-07-06T14:55:35.398Z pw:api => BrowserType.launch started
2021-07-06T14:55:35.942Z pw:api <= BrowserType.launch succeeded
2021-07-06T14:55:35.944Z pw:api => Browser.newContext started
2021-07-06T14:55:36.012Z pw:api <= Browser.newContext succeeded
2021-07-06T14:55:36.014Z pw:api => BrowserContext.newPage started
2021-07-06T14:55:36.302Z pw:api <= BrowserContext.newPage succeeded
2021-07-06T14:55:36.303Z pw:api => Page.navigate started
2021-07-06T14:55:36.315Z pw:api navigating to "https://playwright.dev/java/", waiting until "load"
2021-07-06T14:55:36.436Z pw:api   navigated to "https://playwright.dev/java/"
2021-07-06T14:55:36.638Z pw:api   navigated to "https://ghbtns.com/github-btn.html?user=microsoft&repo=playwright-java&type=star&count=true&size=large"
2021-07-06T14:55:37.070Z pw:api   "domcontentloaded" event fired
2021-07-06T14:55:37.248Z pw:api   "load" event fired
2021-07-06T14:55:37.252Z pw:api <= Page.navigate succeeded
2021-07-06T14:55:37.256Z pw:api => Page.click started
2021-07-06T14:55:37.266Z pw:api waiting for selector "a:text('Get started')"
2021-07-06T14:55:37.419Z pw:api   selector resolved to visible <a class="getStarted_1iQB" href="/java/docs/intro">Get started</a>
2021-07-06T14:55:37.428Z pw:api attempting click action
2021-07-06T14:55:37.429Z pw:api   waiting for element to be visible, enabled and stable
2021-07-06T14:55:37.463Z pw:api   element is visible, enabled and stable
2021-07-06T14:55:37.463Z pw:api   scrolling into view if needed
2021-07-06T14:55:37.465Z pw:api   done scrolling
2021-07-06T14:55:37.469Z pw:api   checking that element receives pointer events at (393.32,348)
2021-07-06T14:55:37.477Z pw:api   element does receive pointer events
2021-07-06T14:55:37.477Z pw:api   performing click action
2021-07-06T14:55:37.531Z pw:api   navigated to "https://playwright.dev/java/docs/intro"
2021-07-06T14:55:37.532Z pw:api   click action done
2021-07-06T14:55:37.532Z pw:api   waiting for scheduled navigations to finish
2021-07-06T14:55:37.767Z pw:api   navigations have finished
2021-07-06T14:55:37.768Z pw:api <= Page.click succeeded
2021-07-06T14:55:37.768Z pw:api => Page.click started
2021-07-06T14:55:37.773Z pw:api waiting for selector "a:text('Docker')"
2021-07-06T14:55:37.935Z pw:api   selector resolved to visible <a tabindex="0" class="menu__link" href="/java/docs…>Docker</a>
2021-07-06T14:55:38.009Z pw:api attempting click action
2021-07-06T14:55:38.009Z pw:api   waiting for element to be visible, enabled and stable
2021-07-06T14:55:38.036Z pw:api   element is visible, enabled and stable
2021-07-06T14:55:38.036Z pw:api   scrolling into view if needed
2021-07-06T14:55:38.037Z pw:api   done scrolling
2021-07-06T14:55:38.039Z pw:api   checking that element receives pointer events at (154.47,1012)
2021-07-06T14:55:38.055Z pw:api   element does receive pointer events
2021-07-06T14:55:38.055Z pw:api   performing click action
2021-07-06T14:55:38.135Z pw:api   navigated to "https://playwright.dev/java/docs/docker"
2021-07-06T14:55:38.135Z pw:api   click action done
2021-07-06T14:55:38.135Z pw:api   waiting for scheduled navigations to finish
2021-07-06T14:55:38.141Z pw:api   navigations have finished
2021-07-06T14:55:38.142Z pw:api <= Page.click succeeded
2021-07-06T14:55:38.145Z pw:api => Page.waitForSelector started
2021-07-06T14:55:38.154Z pw:api waiting for selector "#thisShouldMakeTestFail" to be visible
2021-07-06T14:55:38.162Z pw:api <= Page.waitForSelector failed
com.microsoft.playwright.TimeoutError: Error {
  message='Timeout 1ms exceeded.
=========================== logs ===========================
waiting for selector "#thisShouldMakeTestFail" to be visible
============================================================
Note: use DEBUG=pw:api environment variable to capture Playwright logs.
  name='TimeoutError
  stack='TimeoutError: Timeout 1ms exceeded.
=========================== logs ===========================
waiting for selector "#thisShouldMakeTestFail" to be visible
============================================================
Note: use DEBUG=pw:api environment variable to capture Playwright logs.
    at ProgressController.run (C:\Users\qwpnqjucz\AppData\Local\Temp\2\playwright-java-1435811650143907893\package\lib\server\progress.js:72:30)
    at Frame.waitForSelector (C:\Users\qwpnqjucz\AppData\Local\Temp\2\playwright-java-1435811650143907893\package\lib\server\frames.js:601:27)
    at FrameDispatcher.waitForSelector (C:\Users\qwpnqjucz\AppData\Local\Temp\2\playwright-java-1435811650143907893\package\lib\dispatchers\frameDispatcher.js:63:122)
    at DispatcherConnection.dispatch (C:\Users\qwpnqjucz\AppData\Local\Temp\2\playwright-java-1435811650143907893\package\lib\dispatchers\dispatcher.js:232:46)
}
	at com.microsoft.playwright.impl.WaitableResult.get(WaitableResult.java:52)
	at com.microsoft.playwright.impl.ChannelOwner.runUntil(ChannelOwner.java:94)
	at com.microsoft.playwright.impl.Connection.sendMessage(Connection.java:102)
	at com.microsoft.playwright.impl.ChannelOwner.sendMessage(ChannelOwner.java:85)
	at com.microsoft.playwright.impl.FrameImpl.waitForSelectorImpl(FrameImpl.java:898)
	at com.microsoft.playwright.impl.PageImpl.lambda$waitForSelector$76(PageImpl.java:1354)
	at com.microsoft.playwright.impl.LoggingSupport.withLogging(LoggingSupport.java:47)
	at com.microsoft.playwright.impl.PageImpl.waitForSelector(PageImpl.java:1353)
	at org.example.PlaywrightTest.main(PlaywrightTest.java:32)
Caused by: com.microsoft.playwright.TimeoutError: Error {
  message='Timeout 1ms exceeded.
=========================== logs ===========================
waiting for selector "#thisShouldMakeTestFail" to be visible
============================================================
Note: use DEBUG=pw:api environment variable to capture Playwright logs.
  name='TimeoutError
  stack='TimeoutError: Timeout 1ms exceeded.
=========================== logs ===========================
waiting for selector "#thisShouldMakeTestFail" to be visible
============================================================
Note: use DEBUG=pw:api environment variable to capture Playwright logs.
    at ProgressController.run (C:\Users\qwpnqjucz\AppData\Local\Temp\2\playwright-java-1435811650143907893\package\lib\server\progress.js:72:30)
    at Frame.waitForSelector (C:\Users\qwpnqjucz\AppData\Local\Temp\2\playwright-java-1435811650143907893\package\lib\server\frames.js:601:27)
    at FrameDispatcher.waitForSelector (C:\Users\qwpnqjucz\AppData\Local\Temp\2\playwright-java-1435811650143907893\package\lib\dispatchers\frameDispatcher.js:63:122)
    at DispatcherConnection.dispatch (C:\Users\qwpnqjucz\AppData\Local\Temp\2\playwright-java-1435811650143907893\package\lib\dispatchers\dispatcher.js:232:46)
}
	at com.microsoft.playwright.impl.Connection.dispatch(Connection.java:220)
	at com.microsoft.playwright.impl.Connection.processOneMessage(Connection.java:202)
	at com.microsoft.playwright.impl.ChannelOwner.runUntil(ChannelOwner.java:92)
	... 7 more
2021-07-06T14:55:38.222Z pw:api => BrowserContext.close started
2021-07-06T14:55:39.717Z pw:api <= BrowserContext.close succeeded
2021-07-06T14:55:39.717Z pw:api => Browser.close started
2021-07-06T14:55:39.938Z pw:api <= Browser.close succeeded

Process finished with exit code 0

@yury-s
Copy link
Member

yury-s commented Jul 9, 2021

I don't actually see the "Docker" page rendered on the screen before the browser closes, when I see it rendered the video also contains it:
7f5441d144c1ae13e43108782eeed8c8.webm.zip. Note that the rendering process is asynchronous in Chromium.

@yury-s yury-s closed this as completed Jul 9, 2021
@qwpnqjucz
Copy link
Author

so what's the solution for this? pause at the end of every test?

@qwpnqjucz
Copy link
Author

@yury-s i don't see the docker page in the video you posted either.

@yury-s
Copy link
Member

yury-s commented Jul 12, 2021

@yury-s i don't see the docker page in the video you posted either.

Hmm, this is likely a problem with the player, I'm playing it right in Chrome and see this at the end:

image

@yury-s
Copy link
Member

yury-s commented Jul 13, 2021

so what's the solution for this? pause at the end of every test?

Yeah, the actual painting of the page is asynchronous and may happen with some delay after the navigation has completed and the page was rendered in the web process. We are not planning to add instrumentation for that any time soon so if you need to see the page after the failure you can wait for another 100ms or so before closing the context. This way the GPU process and compositor will get a chance to process pending changes.

For debugging failing tests we recommend trace viewer. In addition to screenshots before/after actions it also captures state of the DOM which may come in handy when debugging problems with your page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants