Skip to content

Is visible checks for offsetWidth which can be equal to 0 #77

@YanaPopovaCharge

Description

@YanaPopovaCharge

https://github.com/sukgu/shadow-automation-selenium/blob/3376e822173d3d62f8d3c4ce4513d785f5cbb659/resources/querySelector.js#L19C2-L19C17

Hi, I am not sure if that's intended, I am using your library for Amplify components and when I set explicit timeout via

  shadow.setExplicitWait(20, 1);

I noticed it always waits for all 20 seconds.

The cycle:

	for(int i = 0 ; i < explicitWait && !visible;) {
		try {
			Thread.sleep(pollingTime * 1000);
			element = (WebElement) executerGetObject(String.format("return getObject(\"%s\");", cssSelector));
			fixLocator(driver, cssSelector, element);
			visible = isPresent(element);
			i = i + pollingTime;
		} catch (InterruptedException e) {
			
		}
	}

Doesn't end because visible always evaluated "false".

var isVisible = function isVisible(object) {
	var visible = object.offsetWidth;
	if(visible>0) {
		return true;
	} else {
		return false;
	}
};

When I check offsetWidth from Chrome Dev Tools I see that it is equal to 0.

I am not sure what that offsetWidth is about, but please consider either doing >= 0 or using something else to detect visibility.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions