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

Method shouldNotBe(exist) throws NoSuchElementException for a non-existent SelenideApiumElement #2665

Closed
232629 opened this issue Feb 29, 2024 · 1 comment · Fixed by #2669
Assignees
Milestone

Comments

@232629
Copy link

232629 commented Feb 29, 2024

The problem

Calling a method $.shouldNot(exist) on a non-existent SelenideAppiumElement throws an error.

Details

Tell us about your environment

  • Selenide-Appium Version: 7.2.0
  • OS Version: Win 10
  • Appium Version: 2.5.1
  • uiautomator2 Version: 2.45.1

Code To Reproduce Issue

public void test() {
    SelenideAppium.$(Selenide.$(By.xpath("Nope"))).shouldNotBe(exist);
}
Element not found {By.xpath: Nope}
Expected: exist
Screenshot: file:/D:/test/Mobile/app5/app5AndroidUI/target/screenshots/1709209344135.0.png
Page source: file:/D:/test/Mobile/app5/app5AndroidUI/target/screenshots/1709209344135.0.xml
Timeout: 30 s.
Caused by: NoSuchElementException: An element could not be located on the page using the given search parameters.

FullStackTrace.txt

@BorisOsipov
Copy link
Member

Reproducible without appium via Selenide test harness with the following test:

final class Foo extends IntegrationTest {
  @Test
  void bar() {
	openFile("page_with_selects_without_jquery.html");
    MissingPage missingPage = PageFactory.initElements(WebDriverRunner.getWebDriver(), MissingPage.class);
    Selenide.$(missingPage.element).shouldNotBe(exist);
  }

  public static class MissingPage {
    @FindBy(xpath = "//select[@name='wrong-select-name']")
    public WebElement element;
  }
}

The culprit is here, where webElementSource.description() underhood calls ElementDescriber to describe a non-existent element and fails.

@asolntsev asolntsev added this to the 7.2.1 milestone Feb 29, 2024
@asolntsev asolntsev self-assigned this Mar 2, 2024
@asolntsev asolntsev linked a pull request Mar 3, 2024 that will close this issue
asolntsev added a commit that referenced this issue Mar 5, 2024
Sonar reported this regex as vulnerable:
"Make sure the regex used here, which is vulnerable to polynomial runtime due to backtracking, cannot lead to denial of service."
asolntsev added a commit that referenced this issue Mar 5, 2024
Sonar reported this regex as vulnerable:
"Make sure the regex used here, which is vulnerable to polynomial runtime due to backtracking, cannot lead to denial of service."
asolntsev added a commit that referenced this issue Mar 7, 2024
I think it's not a problem because the input doesn't comes from users, it comes from Selenium library. And this String has quite limited length.
asolntsev added a commit that referenced this issue Mar 7, 2024
asolntsev added a commit that referenced this issue Mar 7, 2024
Sonar reported this regex as vulnerable:
"Make sure the regex used here, which is vulnerable to polynomial runtime due to backtracking, cannot lead to denial of service."
asolntsev added a commit that referenced this issue Mar 7, 2024
I think it's not a problem because the input doesn't comes from users, it comes from Selenium library. And this String has quite limited length.
asolntsev added a commit that referenced this issue Mar 7, 2024
asolntsev added a commit that referenced this issue Mar 7, 2024
Sonar reported this regex as vulnerable:
"Make sure the regex used here, which is vulnerable to polynomial runtime due to backtracking, cannot lead to denial of service."
asolntsev added a commit that referenced this issue Mar 7, 2024
I think it's not a problem because the input doesn't comes from users, it comes from Selenium library. And this String has quite limited length.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants