Skip to content
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

remove-wait-actions #1907

Merged
merged 13 commits into from
Feb 24, 2025
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
27 changes: 15 additions & 12 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,10 @@
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
Expand All @@ -231,6 +235,10 @@
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
</exclusion>
</exclusions>
</dependency>

Expand Down Expand Up @@ -551,18 +559,7 @@
<artifactId>log4j-core</artifactId>
<version>2.24.3</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-1.2-api -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-1.2-api</artifactId>
<version>2.24.3</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-api -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.24.3</version>
</dependency>

<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
Expand Down Expand Up @@ -670,6 +667,12 @@
<groupId>com.epam.reportportal</groupId>
<artifactId>agent-java-testng</artifactId>
<version>5.4.6</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- https://mvnrepository.com/artifact/com.epam.reportportal/logger-java-log4j -->
<dependency>
Expand Down
18 changes: 3 additions & 15 deletions src/main/java/com/shaft/cucumber/ElementSteps.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import com.shaft.enums.internal.ClipboardAction;
import io.cucumber.java.en.When;
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;

import java.util.Objects;

Expand Down Expand Up @@ -99,20 +98,6 @@ public void typeFileLocationForUpload(String absoluteFilePath, String locatorTyp
driver.get().element().typeFileLocationForUpload(getLocatorFromTypeAndValue(locatorType, locatorValue), absoluteFilePath);
}

/**
* Sends a keypress to the target element. Supported keys are: ENTER, RETURN, TAB.
*
* @param key the key that should be pressed
* @param locatorType can be {id, tagname, classname, name, linktext, partiallinktext, cssselector, xpath}
* @param locatorValue the value/expression of the desired element locator
*/
@SuppressWarnings("SpellCheckingInspection")
@When("I Press the {string} key into the element found by {string}: {string}")
// @عندما("اقوم بالضغط على زر {string} بداخل عنصر الويب المحدد بإستخدام {string} بقيمة {string}")
public void keyPress(String key, String locatorType, String locatorValue) {
driver.get().element().keyPress(getLocatorFromTypeAndValue(locatorType, locatorValue), Keys.valueOf(key.toUpperCase()));
}

/**
* Clicks on a certain element using Selenium WebDriver, or JavaScript.
*
Expand Down Expand Up @@ -244,6 +229,7 @@ public void submitFormUsingJavaScript(String locatorType, String locatorValue) {
* @param locatorValue the value/expression of the desired element locator
*/
@When("I Wait for the element found by {string}: {string} to be present")
@Deprecated
public void waitForElementToBePresent(String locatorType, String locatorValue) {
driver.get().element().waitToBeReady(getLocatorFromTypeAndValue(locatorType, locatorValue));
}
Expand All @@ -258,6 +244,7 @@ public void waitForElementToBePresent(String locatorType, String locatorValue) {
* @param locatorValue the value/expression of the desired element locator
*/
@When("I Wait for the element found by {string}: {string} to be not present")
@Deprecated
public void waitForElementToBeNotPresent(String locatorType, String locatorValue) {
driver.get().element().waitToBeInvisible(getLocatorFromTypeAndValue(locatorType, locatorValue));
}
Expand All @@ -273,6 +260,7 @@ public void waitForElementToBeNotPresent(String locatorType, String locatorValue
* @param initialValue the initial text value of the target webElement
*/
@When("I Wait for the text inside the element found by {string}: {string} to change from the initial value {string}")
@Deprecated
public void waitForTextToChange(String locatorType, String locatorValue, String initialValue) {
driver.get().element().waitForTextToChange(getLocatorFromTypeAndValue(locatorType, locatorValue), initialValue);

Expand Down
17 changes: 0 additions & 17 deletions src/main/java/com/shaft/driver/SHAFT.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import com.shaft.gui.element.AsyncElementActions;
import com.shaft.gui.element.TouchActions;
import com.shaft.gui.element.internal.Actions;
import com.shaft.gui.waits.WaitActions;
import com.shaft.listeners.internal.WebDriverListener;
import com.shaft.tools.io.*;
import com.shaft.tools.io.internal.ReportManagerHelper;
Expand All @@ -26,7 +25,6 @@
import java.io.InputStream;
import java.sql.ResultSet;
import java.util.List;
import java.util.function.Function;

@SuppressWarnings("unused")
public class SHAFT {
Expand Down Expand Up @@ -62,10 +60,6 @@ public Actions element() {
return new Actions(helper);
}

// @Beta public com.shaft.gui.element.internal.Actions newActions(){
// return new com.shaft.gui.element.internal.Actions(helper);
// }

public TouchActions touch() {
return new TouchActions(helper);
}
Expand All @@ -78,17 +72,6 @@ public AlertActions alert() {
return new AlertActions(helper);
}

/**
* Use this method to do any selenium explicit wait if needed. <br>
* Please note that most of the used wait methods are implemented in the related classes (browser and element)
*
* @param conditions Any Selenium explicit wait, also supports <a href="http://appium.io/docs/en/commands/mobile-command/">expected conditions</a>
* @return wait actions reference to be used to chain actions
*/
public WaitActions waitUntil(Function<? super org.openqa.selenium.WebDriver, ?> conditions) {
return new WaitActions(helper).waitUntil(conditions);
}

public WizardHelpers.WebDriverAssertions assertThat() {
return new WizardHelpers.WebDriverAssertions(helper);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ protected void setDriverOptions(DriverFactory.DriverType driverType, MutableCapa
ffOptions.addArguments("-private");
}
ffOptions.setLogLevel(FirefoxDriverLogLevel.WARN);
ffOptions.setPageLoadStrategy(PageLoadStrategy.NONE);
ffOptions.setPageLoadStrategy(PageLoadStrategy.NORMAL);
ffOptions.setPageLoadTimeout(Duration.ofSeconds(SHAFT.Properties.timeouts.pageLoadTimeout()));
ffOptions.setScriptTimeout(Duration.ofSeconds(SHAFT.Properties.timeouts.scriptExecutionTimeout()));
//Add Proxy Setting if found
Expand All @@ -110,7 +110,7 @@ protected void setDriverOptions(DriverFactory.DriverType driverType, MutableCapa
ieOptions = new InternetExplorerOptions();
if (!SHAFT.Properties.platform.executionAddress().equalsIgnoreCase("local"))
ieOptions.setCapability(CapabilityType.PLATFORM_NAME, Properties.platform.targetPlatform());
ieOptions.setPageLoadStrategy(PageLoadStrategy.NONE);
ieOptions.setPageLoadStrategy(PageLoadStrategy.NORMAL);
ieOptions.setPageLoadTimeout(Duration.ofSeconds(SHAFT.Properties.timeouts.pageLoadTimeout()));
ieOptions.setScriptTimeout(Duration.ofSeconds(SHAFT.Properties.timeouts.scriptExecutionTimeout()));
//Add Proxy Setting if found
Expand Down Expand Up @@ -147,7 +147,7 @@ protected void setDriverOptions(DriverFactory.DriverType driverType, MutableCapa
if (!SHAFT.Properties.platform.executionAddress().equalsIgnoreCase("local"))
sfOptions.setCapability(CapabilityType.PLATFORM_NAME, Properties.platform.targetPlatform());
sfOptions.setCapability(CapabilityType.UNHANDLED_PROMPT_BEHAVIOUR, UnhandledPromptBehavior.IGNORE);
sfOptions.setPageLoadStrategy(PageLoadStrategy.NONE);
sfOptions.setPageLoadStrategy(PageLoadStrategy.NORMAL);
sfOptions.setPageLoadTimeout(Duration.ofSeconds(SHAFT.Properties.timeouts.pageLoadTimeout()));
sfOptions.setScriptTimeout(Duration.ofSeconds(SHAFT.Properties.timeouts.scriptExecutionTimeout()));
//Add Proxy Setting if found
Expand Down Expand Up @@ -401,7 +401,8 @@ private ChromiumOptions<?> setupChromiumOptions(ChromiumOptions<?> options, Muta
options.setExperimentalOption("prefs", chromePreferences);
options.setUnhandledPromptBehaviour(UnexpectedAlertBehaviour.IGNORE);
options.setCapability(CapabilityType.ACCEPT_INSECURE_CERTS, true);
options.setPageLoadStrategy(PageLoadStrategy.NONE); // https://www.skptricks.com/2018/08/timed-out-receiving-message-from-renderer-selenium.html
if (DriverFactoryHelper.isNotMobileExecution())
options.setPageLoadStrategy(PageLoadStrategy.NONE); // https://www.skptricks.com/2018/08/timed-out-receiving-message-from-renderer-selenium.html
options.setPageLoadTimeout(Duration.ofSeconds(SHAFT.Properties.timeouts.pageLoadTimeout()));
options.setScriptTimeout(Duration.ofSeconds(SHAFT.Properties.timeouts.scriptExecutionTimeout()));
options.setCapability(CapabilityType.UNHANDLED_PROMPT_BEHAVIOUR, UnhandledPromptBehavior.IGNORE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ public SynchronizationManager(WebDriver driver) {
this.driver = driver;
}

public FluentWait<?> fluentWait() {
public FluentWait<WebDriver> fluentWait() {
return fluentWait(false);
}

public FluentWait<?> fluentWait(boolean isValidToCheckForVisibility) {
public FluentWait<WebDriver> fluentWait(boolean isValidToCheckForVisibility) {
return new FluentWait<>(driver)
.withTimeout(Duration.ofSeconds((long) (SHAFT.Properties.timeouts.defaultElementIdentificationTimeout())))
.pollingEvery(Duration.ofMillis(ELEMENT_IDENTIFICATION_POLLING_DELAY))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,8 @@
import com.shaft.gui.element.TouchActions;
import com.shaft.gui.element.internal.Actions;
import com.shaft.gui.element.internal.ElementActionsHelper;
import com.shaft.gui.waits.WaitActions;
import org.openqa.selenium.WebDriver;

import java.util.function.Function;

public class FluentWebDriverAction {
protected DriverFactoryHelper driverFactoryHelper;
protected WebDriver driver;
Expand Down Expand Up @@ -86,8 +83,4 @@ public BrowserActions browser() {
public FluentWebDriverAction and() {
return this;
}

public WaitActions waitUntil(Function<? super WebDriver, ?> conditions) {
return new WaitActions(driverFactoryHelper).waitUntil(conditions);
}
}
Loading
Loading