Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,70 +6,71 @@
import com.microsoft.playwright.options.Proxy;

public class PropertiesPlaywright {
private Proxy proxy;
private String channel;
private String browsersPath = "./lib/playwright";
private int skipBrowserDownload = 0;
private boolean allowStaticPage = false;
private DriverCloseLevel driverCloseLevel = DriverCloseLevel.CLASS;

@Inject(optional = true)
@SuppressWarnings("unused")
private void setProxy(@Named("playwright.browser.proxy") String proxy) {
this.proxy = new Proxy(proxy);
}

public Proxy getProxy() {
return proxy;
}

@Inject(optional = true)
@SuppressWarnings("unused")
private void setChannel(@Named("playwright.browser.channel") String channel) {
this.channel = channel;
}

public String getChannel() {
return channel;
}

@Inject(optional = true)
@SuppressWarnings("unused")
private void setBrowsersPath(@Named("playwright.browser.downloadPath") String browsersPath) {
this.browsersPath = browsersPath;
}

public String getBrowsersPath() {
return browsersPath;
}

@Inject(optional = true)
@SuppressWarnings("unused")
private void setSkipBrowserDownload(@Named("playwright.browser.skipDownload") int value) {
this.skipBrowserDownload = value;
}

public int getSkipBrowserDownload() {
return skipBrowserDownload;
}

@Inject(optional = true)
@SuppressWarnings("unused")
private void setAllowStaticPage(@Named("playwright.allowStaticPage") boolean value) {
this.allowStaticPage = value;
}

public boolean getAllowStaticPage() {
return allowStaticPage;
}

@Inject(optional = true)
@SuppressWarnings("unused")
private void setDriverCloseLevel(@Named("playwright.driverCloseLevel") String level) {
driverCloseLevel = DriverCloseLevel.fromText(level);
}

public DriverCloseLevel getDriverCloseLevel() {
return driverCloseLevel;
}
private Proxy proxy;
private String channel;
private String browsersPath = "./lib/playwright";
private int skipBrowserDownload = 0;
private boolean allowStaticPage = false;
private DriverCloseLevel driverCloseLevel = DriverCloseLevel.CLASS;

@Inject(optional = true)
@SuppressWarnings("unused")
private void setProxy(@Named("playwright.browser.proxy") String proxy) {
if (!proxy.isEmpty())
this.proxy = new Proxy(proxy);
}

public Proxy getProxy() {
return proxy;
}

@Inject(optional = true)
@SuppressWarnings("unused")
private void setChannel(@Named("playwright.browser.channel") String channel) {
this.channel = channel;
}

public String getChannel() {
return channel;
}

@Inject(optional = true)
@SuppressWarnings("unused")
private void setBrowsersPath(@Named("playwright.browser.downloadPath") String browsersPath) {
this.browsersPath = browsersPath;
}

public String getBrowsersPath() {
return browsersPath;
}

@Inject(optional = true)
@SuppressWarnings("unused")
private void setSkipBrowserDownload(@Named("playwright.browser.skipDownload") int value) {
this.skipBrowserDownload = value;
}

public int getSkipBrowserDownload() {
return skipBrowserDownload;
}

@Inject(optional = true)
@SuppressWarnings("unused")
private void setAllowStaticPage(@Named("playwright.allowStaticPage") boolean value) {
this.allowStaticPage = value;
}

public boolean getAllowStaticPage() {
return allowStaticPage;
}

@Inject(optional = true)
@SuppressWarnings("unused")
private void setDriverCloseLevel(@Named("playwright.driverCloseLevel") String level) {
driverCloseLevel = DriverCloseLevel.fromText(level);
}

public DriverCloseLevel getDriverCloseLevel() {
return driverCloseLevel;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.capgemini.mrchecker.playwright.core.pages;

import com.capgemini.mrchecker.playwright.core.BasePage;

public class TestPage extends BasePage {
@Override
public boolean isLoaded() {
return true;
}

@Override
public void load() {
loadPage("https://google.com/");
}

@Override
public String pageTitle() {
return getActualPageTitle();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ playwright.browser.channel=
playwright.browser.downloadPath=./lib/playwright
playwright.browser.skipDownload=0
playwright.allowStaticPage=false
playwright.driverCloseLevel=class
playwright.driverCloseLevel=class
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package com.capgemini.mrchecker.playwright.core.newDrivers;

import static org.junit.jupiter.api.Assertions.assertTrue;

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Double newline, please use formatter

import org.junit.jupiter.api.*;

import com.capgemini.mrchecker.playwright.core.base.properties.PropertiesPlaywright;
import com.capgemini.mrchecker.playwright.tags.UnitTest;
import com.capgemini.mrchecker.test.core.base.properties.PropertiesSettingsModule;
import com.google.inject.Guice;

@UnitTest
public class DriverManagerTest {
private DriverManager driverManager;

@BeforeAll
public static void setUpBeforeClass() {
}

@AfterAll
public static void tearDownAfterClass() {
}

@BeforeEach
public void setUp() {
PropertiesPlaywright propertiesPlaywright = Guice.createInjector(PropertiesSettingsModule.init())
.getInstance(PropertiesPlaywright.class);

driverManager = new DriverManager(propertiesPlaywright);
driverManager.start();
}

@AfterEach
public void tearDown() {
driverManager.stop();
}

@Test
public void shouldDriverBeCreated() {
assertTrue(DriverManager.wasDriverCreated(), "Driver was not created");
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.capgemini.mrchecker.playwright.tags;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

import org.junit.jupiter.api.Tag;

@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Tag("UnitTest")
public @interface UnitTest {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.capgemini.mrchecker.playwright.unit;

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

import com.capgemini.mrchecker.playwright.core.pages.TestPage;
import com.capgemini.mrchecker.playwright.tags.UnitTest;
import com.capgemini.mrchecker.test.core.BaseTest;
import com.capgemini.mrchecker.test.core.utils.PageFactory;

@UnitTest
class BasePageTest extends BaseTest {

@Test
void testGetPageTitle() {
TestPage testPage = PageFactory.getPageInstance(TestPage.class);
testPage.load();
Assertions.assertEquals("Google", testPage.pageTitle(), "Wrong page title");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package com.capgemini.mrchecker.playwright.unit;

import static org.junit.jupiter.api.Assertions.assertEquals;

import org.junit.jupiter.api.*;
import org.junit.jupiter.api.parallel.ResourceLock;

import com.capgemini.mrchecker.playwright.core.newDrivers.DriverManager;
import com.capgemini.mrchecker.playwright.core.pages.TestPage;
import com.capgemini.mrchecker.playwright.tags.UnitTest;
import com.capgemini.mrchecker.test.core.utils.PageFactory;

@UnitTest
@ResourceLock(value = "SingleThread")
public class DefaultDriverBrowserTest {
@BeforeAll
public static void setUpBeforeClass() {
}

@AfterAll
public static void tearDownAfterClass() {
}

@BeforeEach
public void setUp() {

}

@AfterEach
public void tearDown() {
}

@Test
public void testParameterGetChrome() {
TestPage testPage = PageFactory.getPageInstance(TestPage.class);
testPage.load();
String driverName = DriverManager.getDriver()
.browser()
.browserType()
.name();
assertEquals("chromium", driverName, "Wrong browser name");
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package com.capgemini.mrchecker.playwright.unit;

import static org.junit.jupiter.api.Assertions.assertEquals;

import org.junit.jupiter.api.Test;

import com.capgemini.mrchecker.playwright.core.newDrivers.NewPlaywright;
import com.capgemini.mrchecker.playwright.tags.UnitTest;
import com.microsoft.playwright.Browser;
import com.microsoft.playwright.Playwright;

@UnitTest
public class NewPlaywrightBrowsersTest {
private final NewPlaywright playwright = new NewPlaywright(Playwright.create());

@Test
public void shouldBrowserNameBeFirefox() {
Browser browser = playwright.firefox()
.launch();
assertEquals("firefox", browser.browserType()
.name(), "Wrong browser name");
}

@Test
public void shouldBrowserNameBeChromium() {
Browser browser = playwright.chromium()
.launch();
assertEquals("chromium", browser.browserType()
.name(), "Wrong browser name");
}

@Test
public void shouldBrowserNameBeWebkit() {
Browser browser = playwright.webkit()
.launch();
assertEquals("webkit", browser.browserType()
.name(), "Wrong browser name");
}
}
Loading