Skip to content

Commit

Permalink
Pipeline solidification (#1623)
Browse files Browse the repository at this point in the history
* fix waitToAttribute method logic

* refine browser name mapping to support more variants

- EDGE
- MICROSOFT EDGE
- any values that have spaces and ignoring case

* "-DsetParallelMode=NONE" for failing windows/mac jobs
  • Loading branch information
MohabMohie authored May 23, 2024
1 parent 2bd00b6 commit a6ac0d3
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 19 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/e2eTests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
run: (Get-Item (Get-Command msedge).Source).VersionInfo.ProductVersion
- name: Run tests
continue-on-error: true
run: mvn -e test "-DsetParallelMode=DYNAMIC" "-DsetParallel=METHODS" "-DretryMaximumNumberOfAttempts=1" "-DexecutionAddress=local" "-DtargetOperatingSystem=WINDOWS" "-DtargetBrowserName=MicrosoftEdge" "-DheadlessExecution=true" "-DgenerateAllureReportArchive=true" "-Dtest=!%regex[.*DatabaseActions.*], !%regex[.*DB.*], !%regex[.*Db.*], !%regex[.*db.*], !%regex[.*API.*], !%regex[.*Api.*], !%regex[.*uestBuilder.*], !%regex[.*Rest.*], !%regex[.*Json.*], !%regex[.*JSON.*], !%regex[.*json.*], !%regex[.*ndroid.*], !%regex[.*IOS.*], !%regex[.*obile.*], !%regex[.*CucumberTests.*], !%regex[.*LT.*]"
run: mvn -e test "-DsetParallelMode=NONE" "-DretryMaximumNumberOfAttempts=1" "-DexecutionAddress=local" "-DtargetOperatingSystem=WINDOWS" "-DtargetBrowserName=MicrosoftEdge" "-DheadlessExecution=true" "-DgenerateAllureReportArchive=true" "-Dtest=!%regex[.*DatabaseActions.*], !%regex[.*DB.*], !%regex[.*Db.*], !%regex[.*db.*], !%regex[.*API.*], !%regex[.*Api.*], !%regex[.*uestBuilder.*], !%regex[.*Rest.*], !%regex[.*Json.*], !%regex[.*JSON.*], !%regex[.*json.*], !%regex[.*ndroid.*], !%regex[.*IOS.*], !%regex[.*obile.*], !%regex[.*CucumberTests.*], !%regex[.*LT.*]"
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
Expand Down Expand Up @@ -285,7 +285,7 @@ jobs:
maven-version: 3.9.5
- name: Run tests
continue-on-error: true
run: mvn -e test "-DsetParallelMode=DYNAMIC" "-DsetParallel=METHODS" "-DretryMaximumNumberOfAttempts=1" "-DexecutionAddress=local" "-DtargetOperatingSystem=WINDOWS" "-DtargetBrowserName=chrome" "-DheadlessExecution=true" "-DforceBrowserDownload=true" "-DgenerateAllureReportArchive=true" "-Dtest=!%regex[.*DatabaseActions.*], !%regex[.*DB.*], !%regex[.*Db.*], !%regex[.*db.*], !%regex[.*API.*], !%regex[.*Api.*], !%regex[.*uestBuilder.*], !%regex[.*Rest.*], !%regex[.*Json.*], !%regex[.*JSON.*], !%regex[.*json.*], !%regex[.*ndroid.*], !%regex[.*IOS.*], !%regex[.*obile.*], !%regex[.*CucumberTests.*], !%regex[.*LT.*]"
run: mvn -e test "-DsetParallelMode=NONE" "-DretryMaximumNumberOfAttempts=1" "-DexecutionAddress=local" "-DtargetOperatingSystem=WINDOWS" "-DtargetBrowserName=chrome" "-DheadlessExecution=true" "-DforceBrowserDownload=true" "-DgenerateAllureReportArchive=true" "-Dtest=!%regex[.*DatabaseActions.*], !%regex[.*DB.*], !%regex[.*Db.*], !%regex[.*db.*], !%regex[.*API.*], !%regex[.*Api.*], !%regex[.*uestBuilder.*], !%regex[.*Rest.*], !%regex[.*Json.*], !%regex[.*JSON.*], !%regex[.*json.*], !%regex[.*ndroid.*], !%regex[.*IOS.*], !%regex[.*obile.*], !%regex[.*CucumberTests.*], !%regex[.*LT.*]"
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
Expand Down Expand Up @@ -320,7 +320,7 @@ jobs:
maven-version: 3.9.5
- name: Run tests
continue-on-error: true
run: mvn -e test "-DsetParallelMode=DYNAMIC" "-DsetParallel=METHODS" "-DretryMaximumNumberOfAttempts=1" "-DexecutionAddress=local" "-DtargetOperatingSystem=MAC" "-DtargetBrowserName=chrome" "-DheadlessExecution=true" "-DforceBrowserDownload=true" "-DgenerateAllureReportArchive=true" "-Dtest=${GLOBAL_TESTING_SCOPE}"
run: mvn -e test "-DsetParallelMode=NONE" "-DretryMaximumNumberOfAttempts=1" "-DexecutionAddress=local" "-DtargetOperatingSystem=MAC" "-DtargetBrowserName=chrome" "-DheadlessExecution=true" "-DforceBrowserDownload=true" "-DgenerateAllureReportArchive=true" "-Dtest=${GLOBAL_TESTING_SCOPE}"
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
Expand Down Expand Up @@ -586,7 +586,7 @@ jobs:
- name: Run tests on Windows
if: runner.os == 'Windows'
continue-on-error: true
run: mvn -e test "-DsetParallelMode=DYNAMIC" "-DsetParallel=METHODS" "-DretryMaximumNumberOfAttempts=1" -DexecutionAddress="local" -DtargetOperatingSystem="WINDOWS" -DmaximumPerformanceMode="2" -DtargetBrowserName="MicrosoftEdge" -DgenerateAllureReportArchive="true" -Dtest="%regex[.*CucumberTests.*]"
run: mvn -e test "-DsetParallelMode=NONE" "-DretryMaximumNumberOfAttempts=1" -DexecutionAddress="local" -DtargetOperatingSystem="WINDOWS" -DmaximumPerformanceMode="2" -DtargetBrowserName="MicrosoftEdge" -DgenerateAllureReportArchive="true" -Dtest="%regex[.*CucumberTests.*]"
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,10 @@ protected static void failAction(String testData, Throwable... rootCauseExceptio
private static DriverType getDriverTypeFromName(String driverName) {
int values = DriverType.values().length;
for (var i = 0; i < values; i++) {
if (driverName.trim().toLowerCase().contains(Arrays.asList(DriverType.values()).get(i).getValue().toLowerCase())) {
var expectedName = driverName.trim().toLowerCase();
var supportedName = Arrays.asList(DriverType.values()).get(i).getValue().toLowerCase();

if (expectedName.contains(supportedName) || supportedName.contains(expectedName)) {
return Arrays.asList(DriverType.values()).get(i);
}
}
Expand Down
21 changes: 11 additions & 10 deletions src/main/java/com/shaft/gui/element/ElementActions.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.shaft.cli.FileActions;
import com.shaft.driver.SHAFT;
import com.shaft.driver.internal.DriverFactory.DriverFactoryHelper;
import com.shaft.driver.internal.DriverFactory.SynchronizationManager;
import com.shaft.driver.internal.FluentWebDriverAction;
import com.shaft.driver.internal.WizardHelpers;
import com.shaft.enums.internal.ClipboardAction;
Expand Down Expand Up @@ -960,19 +961,19 @@ public ElementActions waitForTextToChange(By elementLocator, String initialValue
*
* @param elementLocator the locator of the webElement under test (By xpath, id,
* selector, name ...etc.)
* @param att the attribute name of the target webElement
* @param expectedAttValue the expected value of the attribute
* @param attribute the attribute name of the target webElement
* @param expectedValue the expected value of the attribute
* @return a self-reference to be used to chain actions
*/
public ElementActions waitToAttribute(By elementLocator, String att, String expectedAttValue) {
public ElementActions waitToAttribute(By elementLocator, String attribute, String expectedValue) {
try {
var elementName = elementActionsHelper.getElementName(driver, elementLocator);
if (Boolean.FALSE.equals(elementActionsHelper.waitForElementAttributeToBe(driver, elementLocator, att, expectedAttValue))) {
elementActionsHelper.failAction(driver, elementLocator);
}
elementActionsHelper.passAction(driver, elementLocator, Thread.currentThread().getStackTrace()[1].getMethodName(), "wait for element attribute \"" + att + "\" to be \"" + expectedAttValue + "\"", null, elementName);
} catch (Exception throwable) {
elementActionsHelper.failAction(driver, elementLocator, throwable);
new SynchronizationManager(driver).fluentWait(false).until(f -> {
var actualValue = new ElementActions(driver, true).getAttribute(elementLocator, attribute);
return Objects.equals(expectedValue,actualValue);
});
elementActionsHelper.passAction(driver, elementLocator, Thread.currentThread().getStackTrace()[1].getMethodName(), "wait for element attribute \"" + attribute + "\" to be \"" + expectedValue + "\"", null, elementActionsHelper.getElementName(driver,elementLocator));
} catch (TimeoutException timeoutException) {
elementActionsHelper.failAction(driver, elementLocator, timeoutException);
}
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.testng.annotations.*;

public class NegativeValidationsTests {
private static double defaultTimeout = 60;
private final ThreadLocal<WebDriver> driver = new ThreadLocal<>();
private final By button = By.cssSelector("button");
private final By button2 = By.cssSelector("button2");
Expand Down Expand Up @@ -45,9 +46,6 @@ public void title_passing() {
Validations.assertThat().browser(driver.get()).title().isEqualTo("").perform();
}


double defaultTimeout = 60;

@Test(expectedExceptions = AssertionError.class)
public void exists_failing() {
Validations.assertThat().element(driver.get(), button2).exists().perform();
Expand Down Expand Up @@ -139,7 +137,7 @@ public void beforeClass() {
SHAFT.Properties.timeouts.set().defaultElementIdentificationTimeout(2);
}

@AfterClass
@AfterClass(alwaysRun = true)
public void afterClass() {
SHAFT.Properties.timeouts.set().defaultElementIdentificationTimeout(defaultTimeout);
}
Expand Down

0 comments on commit a6ac0d3

Please sign in to comment.