microsoft / playwright-java

Java version of the Playwright testing and automation library
https://playwright.dev/java/
Apache License 2.0
1.07k stars 195 forks source link

[Bug]: Traceviewer not reporting all actions #1617

Open ShanmukhaGajula opened 5 days ago

ShanmukhaGajula commented 5 days ago

Version

1.45.0

Steps to reproduce

public String Input_locator_basedonLabel(String label) {
        if(label.equalsIgnoreCase("Client Industry")) {
            return "//*[@class='ajax__tab_panel' and @style='visibility: visible;']//*[text()='"+label+": ']/parent::tr//*[self::textarea or self::input or self::select]";
        }
        else {
            return "//*[@class='ajax__tab_panel' and @style='visibility: visible;']//*[text()='"+label+":']/parent::tr//*[self::textarea or self::input or self::select]";
        }

    }
 public void fill_opp_details() {
          page.fill(Input_locator_basedonLabel("Opportunity Name"), "Shanmukha Playwright Java Opportunity");
          page.fill(Input_locator_basedonLabel("Opportunity Owner"), "Shanmukha Gajula");
          page.fill(Input_locator_basedonLabel("Account Name"), "Shanmukha Playwright Java Account");
          page.locator("text='SF Other Details'").click();
          page.fill(Input_locator_basedonLabel("Comments"), "Shanmukha Playwright Java");
          page.fill(Input_locator_basedonLabel("Main Competitor"), "Shanmukha ");
          page.locator(Input_locator_basedonLabel("Client Industry")).selectOption("Manufacturing");
     }

Expected behavior

To have all the actions in the Traceviewer

Actual behavior

though script is performing all the actions only recent log of fill, select are being shown in trace viewer

image

Additional context

No response

Environment

Java version : 21 Browser : chromium Operating System: Windows 11 Platform: win32

mxschmitt commented 4 days ago

would it be possible to provide a reproduction which we can run locally? Ideally a single file, e.g. starting from here.

ShanmukhaGajula commented 2 days ago

would it be possible to provide a reproduction which we can run locally? Ideally a single file, e.g. starting from here.

import java.nio.file.Paths;

import com.microsoft.playwright.Browser;
import com.microsoft.playwright.BrowserContext;
import com.microsoft.playwright.BrowserType;
import com.microsoft.playwright.Page;
import com.microsoft.playwright.Playwright;
import com.microsoft.playwright.Tracing;

public class Test {
  public static void main(String[] args) {
    try (Playwright playwright = Playwright.create()) {
      Browser browser = playwright.chromium().launch(new BrowserType.LaunchOptions()
        .setHeadless(false));
      BrowserContext context = browser.newContext();
   // Start tracing before creating / navigating a page.
      context.tracing().start(new Tracing.StartOptions()
        .setScreenshots(true)
        .setSnapshots(true)
        .setSources(true));
      Page page = context.newPage();
      page.navigate("https://letcode.in/edit");
      page.getByPlaceholder("Enter first & last name").click();
      page.getByPlaceholder("Enter first & last name").fill("test");
      page.getByPlaceholder("Enter first & last name").press("Tab");
      page.locator("#join").fill("rtste");
      page.locator("#join").press("Tab");
      page.locator("#getMe").fill("sdfhbdsf");
      page.locator("#getMe").press("Tab");
      page.locator("#clearMe").fill("dfhbsdfgbsdf");
      page.locator("#dontwrite").click();
   // Stop tracing and export it into a zip archive.
      context.tracing().stop(new Tracing.StopOptions()
        .setPath(Paths.get("trace.zip")));
    }
  }
}
ShanmukhaGajula commented 2 days ago

But it reported these actions only image

ShanmukhaGajula commented 2 days ago

would it be possible to provide a reproduction which we can run locally? Ideally a single file, e.g. starting from here.

Hi @mxschmitt, I have provided a single file, and I'm able to reproduce the issue. Please validate from your side using version 1.45.0