1

I looking at playwright and I want to return a response I have looked at the examples and there is the following snippit

Response resp = page.navigate(getPageRequest.getUrl(), new Page.NavigateOptions().setTimeout(60000));

But what I want to do is loggin on the first page which is a loggon page which will return the main page , and that page, I want to return the response, so I have the following code

// This page is the loggin page
page.navigate(logginURL, new Page.NavigateOptions().setTimeout(60000));
                    String title = page.title();
                    System.out.println("title : "+title);
                    page.fill("input[name='username']", "MyName");
                    page.fill("input[name='password']", "MyPassword");
                    page.click("text=Login");
                    Thread.sleep(300);
                    // This is the main page after a successful login
                    title = page.title();

Is there a way to navigate to a page login and return the successful have logged in page

Tony
  • 363
  • 3
  • 17

1 Answers1

0

I worked out a way, he feels hacky but I dont know playwright enough to know if there is a better way. Navigate to the login page, login, returns new page navigate to that page url.

page.navigate(getPageRequest.getUrl(), new Page.NavigateOptions().setTimeout(60000));
                    String title = page.title();
                    System.out.println("title : "+title);
                    page.fill("input[name='username']", "MyName");
                    page.fill("input[name='password']", "MyPassword");
                    page.click("text=Login");
                    Thread.sleep(300);
                    System.out.println("title : "+page.title());
                    System.out.println("URL : "+page.url());
                    resp = page.navigate(page.url(), new Page.NavigateOptions().setTimeout(60000));
Tony
  • 363
  • 3
  • 17