[BUG] isPresent() does not return false when element not found in DOM
See original GitHub issueBug Report:
- Node Version: 8.1.4, 6.9.1, 6.9.2
- Protractor Version: 5.1.2
- Angular Version: non-angular. we use react
- Browser(s): chrome 59.0
- Operating System and Version: wins10
Description:
I’m checking a checkbox status and hope to receive True or False. Here is checkbox element in DOM (unselected by default):
<input type="checkbox" value="on"> </input>
If it is selected, the element in DOM will be changed to
<input type="checkbox" value="on"> ::after </input>
So, I use the following css to detect the checkbox when it is selected:
locator = by.css("div[class*='EchoFilterBar'] label[class*='EchoCheckbox']>input:checked");
Suppose that the checkbox is unselected, the locator will be non-existing in DOM and isPresent()
should return to false
. However, it does not work like that. when the locator not existing in DOM, protractor keeps looking the element until timeout.
element(locator).isPresent()
.then((value) => {
expect(value).toBe(false)
});
P/S: isPresent() works okay in true case, i.e, if xpath existing in DOM it returns to True correctly.
Issue Analytics
- State:
- Created 6 years ago
- Comments:9 (4 by maintainers)
Top GitHub Comments
hey guys, i need some help whit this issue.
i’m trying to test if an element is not present whit this function:
Then(/^la opción Eliminar no se encuentra$/, function (callback) { browser.waitForAngular().then(function() { page.matRowArray.isPresent().then(function () { page.productInput.isPresent().then(function (button) { expect(button).to.equal(false); browser.sleep(1000).then(function () { console.log(‘no se puede eliminar el articulo’); callback(); }); }); }); }); }); but get no response from the browser or the GUI say that : (node:88992) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): NoSuchElementError: No element found using locator: By(css selector, *[name=“productInput”])
this is driving me crazy, please helpme!!
@flucena89 You are more likely to get a response if you format your code properly.