Skip to content

left over changes merged #67

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Aug 7, 2024
Merged
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
12 changes: 11 additions & 1 deletion src/test/java/io/github/mfaisalkhatri/tests/MouseHoverTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ public class MouseHoverTest {
private Playwright playwright;
private Page page;


@BeforeClass
public void setup() {
this.playwright = Playwright.create();
Expand All @@ -30,6 +29,17 @@ public void testMouseHover() {
assertThat(userNameText).hasText("name: user1");
}

@Test
public void testMouseHoverOnMyAccountLink() {
page.navigate("https://ecommerce-playground.lambdatest.io/");
Locator myAccountLink = page.locator("#widget-navbar-217834 > ul > li:nth-child(6) > a");
myAccountLink.hover();
Locator loginLink = page.locator("#widget-navbar-217834 > ul > li:nth-child(6) > ul > li:nth-child(1) > a");
loginLink.click();
Locator pageHeader = page.getByRole(AriaRole.HEADING, new Page.GetByRoleOptions().setName("Returning Customer"));
assertThat(pageHeader).hasText("Returning Customer");
}

@AfterClass
public void tearDown() {
this.page.close();
Expand Down
49 changes: 49 additions & 0 deletions src/test/java/io/github/mfaisalkhatri/tests/RadioButtonTests.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package io.github.mfaisalkhatri.tests;

import com.microsoft.playwright.*;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

import static com.microsoft.playwright.assertions.PlaywrightAssertions.assertThat;

public class RadioButtonTests {

private Playwright playwright;
private Page page;


@BeforeClass
public void setup() {
this.playwright = Playwright.create();
final Browser browser = playwright.chromium().launch(new BrowserType.LaunchOptions().setHeadless(false).setChannel("chrome"));
this.page = browser.newPage();
}

@Test
public void testRadioButtonIsChecked() {
page.navigate("https://www.lambdatest.com/selenium-playground/radiobutton-demo");
Locator maleRadioBtn = page.getByLabel("Male").first();
maleRadioBtn.click();
assertThat(maleRadioBtn).isChecked();
}

@Test
public void testRadioButtonIsNotChecked() {
page.navigate("https://www.lambdatest.com/selenium-playground/radiobutton-demo");
Locator femaleRadioBtn = page.getByLabel("Female").first();
femaleRadioBtn.click();
assertThat(femaleRadioBtn).isChecked();

Locator maleRadioBtn = page.getByLabel("Male").first();
assertThat(maleRadioBtn).not().isChecked();
}


@AfterClass
public void tearDown() {
this.page.close();
this.playwright.close();
}

}
1 change: 1 addition & 0 deletions test-suites/testng-mousehovertest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<class name="io.github.mfaisalkhatri.tests.MouseHoverTest">
<methods>
<include name="testMouseHover"/>
<include name="testMouseHoverOnMyAccountLink"/>
</methods>
</class>
</classes>
Expand Down
14 changes: 14 additions & 0 deletions test-suites/testng-radiobuttons.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Playwright demo test suite ">
<test name="Radio buttons demo on Chrome">
<classes>
<class name="io.github.mfaisalkhatri.tests.RadioButtonTests">
<methods>
<include name="testRadioButtonIsChecked"/>
<include name="testRadioButtonIsNotChecked"/>
</methods>
</class>
</classes>
</test>
</suite>
1 change: 1 addition & 0 deletions test-suites/testng.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@
<suite-file path="testng-textfielddemo.xml"/>
<suite-file path="testng-mousehovertest.xml"/>
<suite-file path="testng-playwrightdemotests.xml"/>
<suite-file path="testng-radiobuttons.xml"/>
</suite-files>
</suite>
Loading