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

Stack overflow when printing missing element #2282

Open
Pawel-12 opened this issue Jul 31, 2024 · 0 comments
Open

Stack overflow when printing missing element #2282

Pawel-12 opened this issue Jul 31, 2024 · 0 comments
Labels

Comments

@Pawel-12
Copy link

Describe the bug

If inside class that inherits from ExtendedWebElement (AbstractUIObject) there is method that uses isElementPresent() or isPresent() or isVisible() on ExtendedWebElement that isn`t present on page and there is overridden toString() that uses that method it causes infinite loop and stack overflow.

Example:

package com.solvd;
​
import com.zebrunner.carina.webdriver.decorator.ExtendedWebElement;
import com.zebrunner.carina.webdriver.gui.AbstractPage;
import com.zebrunner.carina.webdriver.gui.AbstractUIObject;
import org.openqa.selenium.SearchContext;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.support.FindBy;
​
import java.time.Duration;
​
public class Main {
    public static class Component extends AbstractUIObject {
        @FindBy(className = "imerror")
        private ExtendedWebElement notExistingElement;
​
        public Component(WebDriver driver, SearchContext searchContext) {
            super(driver, searchContext);
        }
​
        public String getNotExistingElement() {
            System.out.println(notExistingElement);
            if (notExistingElement.isElementPresent(Duration.ofMillis(100))) // causes infinite loop
            {/*code*/}
​
            return "missing";
        }
​
        @Override
        public String toString() {
            return getNotExistingElement();
        }
    }
​
    public static class Page extends AbstractPage {
        @FindBy(id = "error?")
        private Component component;
​
        public Page(WebDriver driver) {
            super(driver);
            setPageAbsoluteURL("https://www.google.com");
        }
​
        public String getComponent() {
            return component.toString();
        }
    }
​
    public static void main(String[] args) {
    WebDriver driver = new ChromeDriver();
​
    Page page = new Page(driver);
    page.open();
    System.out.println(page.getComponent());
    }
}

Logs/Links

Exception in thread "main" java.lang.StackOverflowError
    at java.base/java.lang.String.indexOf(String.java:2447)
    at java.base/java.net.URLStreamHandler.parseURL(URLStreamHandler.java:157)
    at java.base/sun.net.www.protocol.file.Handler.parseURL(Handler.java:56)
    at java.base/java.net.URL.<init>(URL.java:801)
    at java.base/java.net.URL.<init>(URL.java:654)
    at java.base/jdk.internal.loader.URLClassPath$FileLoader.getResource(URLClassPath.java:1053)
    at java.base/jdk.internal.loader.URLClassPath.getResource(URLClassPath.java:316)
    at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:757)
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:681)
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:639)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:525)
    at org.openqa.selenium.support.ui.FluentWait.propagateIfNotIgnored(FluentWait.java:248)
    at org.openqa.selenium.support.ui.FluentWait.until(FluentWait.java:215)
    at com.zebrunner.carina.webdriver.helper.IWaitHelper.waitUntil(IWaitHelper.java:71)
    at com.zebrunner.carina.webdriver.helper.IWaitHelper.waitUntil(IWaitHelper.java:37)
    at com.zebrunner.carina.webdriver.decorator.ExtendedWebElement.isElementPresent(ExtendedWebElement.java:337)
    (...)

Web (please complete the following information):

  • Browser chrome
  • Version 127
@Pawel-12 Pawel-12 added the bug label Jul 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant