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

[Bug]: Test case Fails due to Click Action Fails When GIF or (Screenshot Properties = Alaways) Are Enabled #1913

Open
nouralaa96 opened this issue Feb 26, 2025 · 1 comment
Assignees
Labels
bug Something isn't working triage needs to be looked at

Comments

@nouralaa96
Copy link

nouralaa96 commented Feb 26, 2025

Describe the bug

When screenshotParamsWhenToTakeAScreenshot=Always OR createAnimatedGif=true, the test fails when performing a click action on an element that disappears after the click(like after click we go to new page and clicked element isnt there). I beleive The failure occurs in performAction(ActionType action, By locator, Object data) method, specifically in this part
if (screenshot[0] != null) { screenshot[0] = this.takeActionScreenshot((WebElement)((List)foundElements.get()).getFirst()); }
This results in a failure that prevents the test from continuing.

Link to SHAFT_Engine Console logs
Full console logs: Gist Link

Environment

  1. SHAFT_Engine version that exhibits the issue (9.1.20250216 and before vesion):
  2. Last SHAFT_Engine version that did not exhibit the issue (if applicable): not sure
  3. Desktop OS: [ mac]
  4. Desktop Browser (if applicable): [ chrome]
  5. Desktop Browser Version (if applicable): latest

To Reproduce

Enable GIF creation OR Always take a screenshot in custom
properties File

shaftEngine.screenshotParamsWhenToTakeAScreenshot=Always  
shaftEngine.createAnimatedGif=true 

Run a test case that clicks on an element that disappears immediately after the action.
The screenshot attempt fails, causing the test case to halt instead of proceeding.
test case example form the template project :
` @step("And I search for '{query}'.")
public Results searchForQuery(String query){
driver.element().type(searchBox, query)
.typeAppend(searchBox, String.valueOf(Keys.ENTER));

        driver.element().click(By.xpath("//div[contains(text(),'صور')]"));
        driver.element().click(By.xpath("//div[contains(text(),'الكل')]"));
      driver.element().click(By.xpath("//*[@id=\"logo\"]"));
      driver.element().type(searchBox, query)
            .typeAppend(searchBox, String.valueOf(Keys.ENTER));

    return new Results(driver);
}` 

@Epic("SHAFT Web GUI Template") @Story("Google Basic Validations")@TmsLink("TC-002") @Description("Given I am on the Home page,\nWhen I search for a valid query,\nThen the result stats will show some data (will not be empty).") @Test(description = "Check that Result Stats is not empty after searching for a query.") public void checkResultStatsIsNotEmptyAfterSearchingForAQuery() { new Home(driver).searchForQuery(testData.getTestData("searchQuery")) .assertResultStatsIsNotEmpty(); }

Expected behavior

case run scussfully and gif created correctly ,without failling the test case.

like when this property is not

Screenshots
for failled while enable gif property
2025-02-26_11-15-50-353_AllureReport.html.zip

diable gif property works fine 👍
2025-02-26_11-12-59-017_AllureReport.html.zip

Additional context
this issues some times on my frameWork raise other Exception but i think all are for the same resaon like this
Root cause: "org.openqa.selenium.WebDriverException: unknown error: unhandled inspector error: {"code":-32000,"message":"Node with given id does not belong to the document"}" java.lang.RuntimeException: Root cause: "org.openqa.selenium.WebDriverException: unknown error: unhandled inspector error: {"code":-32000,"message":"Node with given id does not belong to the document"}" at com.shaft.gui.element.internal.Actions.report(Actions.java:501) at com.shaft.gui.element.internal.Actions.reportBroken(Actions.java:462) at com.shaft.gui.element.internal.Actions.performAction(Actions.java:246) at com.shaft.gui.element.internal.Actions.click(Actions.java:68) at focal.pages.login.Login.fillUsernameAndPasswordForAuditorRole(Login.java:79) at TestPackage.Screening.rs(IndividualBatchRecordsTests.java:174) at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103) at java.base/java.lang.reflect.Method.invoke(Method.java:580) at org.testng.internal.invokers.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:141)

The issue seems to originate from the performAction method when handling disappearing elements.
A potential fix might involve handling StaleElementReferenceException when taking screenshots.

@nouralaa96 nouralaa96 added bug Something isn't working triage needs to be looked at labels Feb 26, 2025
@nouralaa96 nouralaa96 changed the title [Bug]: Test case Fails due to Click Action Fails When GIF or Screenshot Properties = Alaways Are Enabled [Bug]: Test case Fails due to Click Action Fails When GIF or (Screenshot Properties = Alaways) Are Enabled Feb 26, 2025
@nouralaa96
Copy link
Author

nouralaa96 commented Feb 26, 2025

believe this issue was resolved with the latest release yesterday, although running with gif property for now take two much time like more than 30 sec for cases can be done in 3 sec. Apologies for creating . However, it would be a good practice to review older versions to understand why this happened, verify everything is working correctly, and ensure no further enhancements are needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triage needs to be looked at
Projects
None yet
Development

No branches or pull requests

2 participants