I have started dabbing with Playwright-Java. So part of it I wrote a simple script. While running it I came across an exception whenever I try to navigate to a url which resides within our org’s network. I am connected to VPN though. The script is as below
package com.karna.maven_playwright;
import org.testng.Assert;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
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.Page.NavigateOptions;
public class pwtest {
Browser browser;
BrowserContext browserContext;
Page page;
@BeforeMethod
public void setup() {
Playwright pw = Playwright.create();
browser = pw.chromium().launch(new BrowserType.LaunchOptions().setChannel("chrome").setHeadless(false));
browserContext = browser.newContext();
page = browserContext.newPage();
}
@Test
public void test() {
NavigateOptions no = new NavigateOptions();
no.setTimeout(0);
page.navigate("url", no);
String title = page.title();
Assert.assertEquals(title, "Google");
}
@AfterMethod
public void tearDown() {
page.close();
browser.close();
}
}
I initially tried without passing Navigation Options. Still the same exception. Then I tried with Navigation Options
New contributor
Karna Diwakar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.