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

In Firefox when clicking on a non-working link (for example, https://example), Selenide displays an error: #2725

Closed
BorisOsipov opened this issue Apr 24, 2024 · 2 comments · Fixed by #2727
Assignees
Labels
Milestone

Comments

@BorisOsipov
Copy link
Member

BorisOsipov commented Apr 24, 2024

In Firefox when clicking on a non-working link (for example, https://example), Selenide displays an error:

Element not found {#link}
Expected: clickable: interactable and enabled

Stacktrace https://pastebin.com/0FEnA98C

But in Selenium, when performing similar actions, another error is displayed:

org.openqa.selenium.WebDriverException: Reached error page: about:neterror?e=dnsNotFound&u=https%3A//example/&c=UTF-8&d=We%20can%E2%80%99t%20connect%20to%20the%20server %20at%20example.

In Chrome and Safari these tests are green.

My question is where is the correct error: in Selenide or Selenium? It looks like there is a more accurate error in Selenium.

And maybe in Chrome and Safari the test should fail, because according to the standard W3C, following a link should also be checked and the response status should be returned?


Minimum code to reproduce:

import com.codeborne.selenide.Configuration;
import com.codeborne.selenide.junit5.TextReportExtension;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
import org.openqa.selenium.By;

import static com.codeborne.selenide.Selenide.*;

@ExtendWith(TextReportExtension.class)
class ClickNavigateTest {

    @ParameterizedTest
    @ValueSource(strings = {"chrome", "firefox", "safari"})
    void seleniumClickNavigateTest(String browser) {
        closeWebDriver();
        Configuration.browser = browser;
        open("/your_html_file.html");
        webdriver().object().findElement(By.id("link")).click();
    }

    @ParameterizedTest
    @ValueSource(strings = {"chrome", "firefox", "safari"})
    void selenideClickNavigateTest(String browser) {
        closeWebDriver();
        Configuration.browser = browser;
        open("/your_html_file.html");
        $("#link").click();
    }
}

HTML:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<a href="https://example" id="link">Link</a>
</body>
</html>

Versions:

Selenide 7.2.3
JUnit 5.9.1

Originally posted by @prafair in #2724

@BorisOsipov
Copy link
Member Author

I guess the problem is that Selenide underhood can retry failed clicks with WebDriverException: Reached error page. Obviously, on a broken page, there is no #link, and you receive the wrong last error

@BorisOsipov
Copy link
Member Author

Solution - dont retry WebDriverException with the message matches ^Reached error page:.* regex.

@asolntsev asolntsev added this to the 7.2.4 milestone Apr 24, 2024
@asolntsev asolntsev self-assigned this Apr 25, 2024
asolntsev added a commit that referenced this issue Apr 25, 2024
... when user clicks a link with invalid URL, and Firefox throws an error like "Reached error page: about:neterror?e=dnsNotFound..."
@asolntsev asolntsev linked a pull request Apr 25, 2024 that will close this issue
asolntsev added a commit that referenced this issue Apr 25, 2024
... when user clicks a link with invalid URL, and Firefox throws an error like "Reached error page: about:neterror?e=dnsNotFound..."
asolntsev added a commit that referenced this issue Apr 25, 2024
... when user clicks a link with invalid URL, and Firefox throws an error like "Reached error page: about:neterror?e=dnsNotFound..."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants