Merge branch 'eugenp:master' into PR-7091

This commit is contained in:
parthiv39731
2023-11-16 20:28:19 +05:30
committed by GitHub
571 changed files with 8610 additions and 3248 deletions
+13 -2
View File
@@ -45,7 +45,18 @@
<version>${junit-platform.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-launcher</artifactId>
<version>${junit-platform.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-commons</artifactId>
<version>${junit-platform.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
@@ -70,7 +81,7 @@
<properties>
<jmockit.version>1.49</jmockit.version>
<assertj.version>3.24.2</assertj.version>
<junit-platform.version>1.9.2</junit-platform.version>
<junit-platform.version>1.10.1</junit-platform.version>
<maven-surefire-plugin.version>3.0.0</maven-surefire-plugin.version>
</properties>
@@ -10,4 +10,8 @@ public class ClassOneUnitTest {
Assertions.assertTrue(true);
}
@Test
public void whenFalse_thenFalse() {
Assertions.assertFalse(false);
}
}
@@ -8,4 +8,9 @@ public class ClassTwoUnitTest {
public void whenTrue_thenTrue() {
Assertions.assertTrue(true);
}
@Test
public void whenFalse_thenFalse() {
Assertions.assertFalse(false);
}
}
@@ -0,0 +1,14 @@
package com.baeldung.testsuite.suites;
import com.baeldung.testsuite.ClassOneUnitTest;
import org.junit.platform.suite.api.SelectMethod;
import org.junit.platform.suite.api.Suite;
import org.junit.platform.suite.api.SuiteDisplayName;
@Suite
@SuiteDisplayName("My Test Suite")
@SelectMethod(type = ClassOneUnitTest.class, name = "whenFalse_thenFalse")
@SelectMethod("com.baeldung.testsuite.subpackage.ClassTwoUnitTest#whenFalse_thenFalse")
public class JUnitSelectMethodsSuite {
// runs ClassOneUnitTest and ClassTwoUnitTest
}
+5 -4
View File
@@ -1,16 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>junit-5-basics-2</artifactId>
<parent>
<groupId>com.baeldung</groupId>
<artifactId>parent-modules</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<artifactId>junit-5-basics-2</artifactId>
<dependencies>
<dependency>
<groupId>commons-cli</groupId>
@@ -30,6 +30,7 @@
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
-6
View File
@@ -93,11 +93,6 @@
<artifactId>mail</artifactId>
<version>${javax.mail.version}</version>
</dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>${joda-time.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
@@ -184,7 +179,6 @@
<httpclient.version>4.5.2</httpclient.version>
<uri-template.version>0.9</uri-template.version>
<libphonenumber.version>8.0.0</libphonenumber.version>
<joda-time.version>2.9.6</joda-time.version>
<msg-simple.version>1.1</msg-simple.version>
<btf.version>1.2</btf.version>
<wiremock.version>2.27.2</wiremock.version>
@@ -0,0 +1,120 @@
package com.baeldung.selenium.iframe;
import io.github.bonigarcia.wdm.WebDriverManager;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import java.time.Duration;
public class IframeManualTest {
private WebDriver driver;
private static final int TIMEOUT = 10;
@BeforeMethod
public void init() {
WebDriverManager.chromedriver().setup();
driver = new ChromeDriver();
}
@Test
public void whenSwitchToFrameUsingWebElement_thenSwitched() {
openDemoPage();
WebElement iframeElement = driver.findElement(By.cssSelector("#myFrame2"));
new WebDriverWait(driver, Duration.ofSeconds(10))
.until(ExpectedConditions.frameToBeAvailableAndSwitchToIt(iframeElement));
waitForTextInFrame();
}
@Test
public void whenSwitchToFrameUsingName_thenSwitched() {
openDemoPage();
new WebDriverWait(driver, Duration.ofSeconds(10))
.until(ExpectedConditions.frameToBeAvailableAndSwitchToIt("frameName2"));
waitForTextInFrame();
}
@Test
public void whenSwitchToFrameUsingId_thenSwitched() {
openDemoPage();
new WebDriverWait(driver, Duration.ofSeconds(10))
.until(ExpectedConditions.frameToBeAvailableAndSwitchToIt("myFrame2"));
waitForTextInFrame();
}
@Test
public void whenSwitchToInnerFrameFromOuter_thenSwitched() {
openPageWithNestedFrames();
switchToNestedFrame();
waitForLinkInNestedFrame();
}
@Test
public void whenSwitchToParentFrame_thenSwitched() {
openPageWithNestedFrames();
switchToNestedFrame();
driver.switchTo().parentFrame();
waitForTextInParentFrame();
}
@Test
public void whenSwitchToDefaultContent_thenSwitched() {
openPageWithNestedFrames();
switchToNestedFrame();
driver.switchTo().defaultContent();
waitForElementInDefaultContent();
}
@AfterMethod
public void tearDown() {
driver.quit();
}
private void openDemoPage() {
driver.get("https://seleniumbase.io/demo_page");
new WebDriverWait(driver, Duration.ofSeconds(10))
.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("#myForm")));
}
private void openPageWithNestedFrames() {
driver.get("https://seleniumbase.io/w3schools/iframes");
new WebDriverWait(driver, Duration.ofSeconds(10))
.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("#runbtn")));
}
private void switchToNestedFrame() {
driver.switchTo().frame("iframeResult");
WebElement innerFrame = driver.findElement(By.cssSelector("[src='./demo_iframe.htm']"));
driver.switchTo().frame(innerFrame);
}
private void waitForTextInFrame() {
new WebDriverWait(driver, Duration.ofSeconds(TIMEOUT))
.until(ExpectedConditions.textToBePresentInElementLocated(By.cssSelector("h4"), "iFrame Text"));
}
private void waitForLinkInNestedFrame() {
new WebDriverWait(driver, Duration.ofSeconds(TIMEOUT))
.until(ExpectedConditions.presenceOfElementLocated(By.cssSelector("[href='https://seleniumbase.io/w3schools/iframes.html']")));
}
private void waitForTextInParentFrame() {
new WebDriverWait(driver, Duration.ofSeconds(TIMEOUT))
.until(ExpectedConditions.textToBePresentInElementLocated(By.cssSelector("h2"), "HTML Iframes (nested iframes)"));
}
private void waitForElementInDefaultContent() {
new WebDriverWait(driver, Duration.ofSeconds(TIMEOUT))
.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("#runbtn")));
}
}