DEV Community

lizhiping
lizhiping

Posted on

1

Playwright For Java Test Web TIKTOK PAGE

I use Playwright FOR JAVA to test the WEB TIKTOK LIVE PAGE ,
which will result in the absence of barrage on the WEB TIKTOK LIVE PAGE , Even if I log in to my TikTok account , the page only prompts me for my account to enter the live broadcast room

It seems that the automated testing software has been detected,My code has simulated UserAgent

I would like to know the solution for this,Thank you.


  try (Playwright playwright = Playwright.create()) {
            Path userDataDir = Paths.get("C:\\Users\\wu\\AppData\\Local\\Google\\Chrome\\User Data\\playwright");
            BrowserContext browserContext  = playwright.chromium().launchPersistentContext(userDataDir,
                    new BrowserType.LaunchPersistentContextOptions()
                            .setHeadless(false)
                            .setSlowMo(500)
                            .setUserAgent("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36")
            );


            Page page = null;
            List<Page> pages = browserContext.pages();
            if(pages!=null && pages.size()>0){
                page = pages.get(0);
            }
            if(page==null){
                System.out.println("page is null");
                return;
            }

            while (true) {
                try {
                    if(pageOut!=null){
                        pageOut.content();
                    }
                    Thread.sleep(5000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
  }


Enter fullscreen mode Exit fullscreen mode

Qodo Takeover

Introducing Qodo Gen 1.0: Transform Your Workflow with Agentic AI

While many AI coding tools operate as simple command-response systems, Qodo Gen 1.0 represents the next generation: autonomous, multi-step problem-solving agents that work alongside you.

Read full post

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay