Skip to content
This repository was archived by the owner on Jul 29, 2024. It is now read-only.

[issue] .isDisplayed() returning error "Failed: No element found using locator:" in Firefox, works fine in Chrome #2960

Closed
amcinerney opened this issue Feb 18, 2016 · 3 comments

Comments

@amcinerney
Copy link

Hello, I am currently running protractor tests in both firefox 44 and chrome 48, I have run into an issue several times where elements with display = none return a failure message when using the .isDisplayed() method.

var uploadFileButton = element(by.id('uploadFile')); uploadFileButton.isDisplayed().then(function(result){ if(!result){ //create a new folder and navigate into it }; });

The above code results in the error Failed: No element found using locator: By.id("uploadFile")

This error is strange to me because if I do the same snippet of code in chrome it works. If I do the same snippet of code in firefox but replace .isDisplayed() with .isPresent() then result = false, and I do not get the same error.

Additionally if I do
uploadFileButton.isPresent().then(function(result){
in chrome then result = true.

Has anyone seen this behavior before or know a workaround when working with the two different browsers?

Using protractor version 3.1.1

@amcinerney
Copy link
Author

> [firefox #2]   Message:
> [firefox #2]     Failed: No element found using locator: By.id("uploadFile")
> [firefox #2]   Stack:
> [firefox #2]     NoSuchElementError: No element found using locator: By.id("uploadFile")
> [firefox #2]         at new bot.Error (C:\Users\amcinerney\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\atoms\error.js:108:18)
> [firefox #2]         at C:\Users\amcinerney\AppData\Roaming\npm\node_modules\protractor\lib\element.js:674:15
> [firefox #2]         at goog.async.run.processWorkQueue (C:\Users\amcinerney\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\goog\async\run.js:124:15)
> [firefox #2]         at process._tickCallback (node.js:366:9)
> [firefox #2]     Error
> [firefox #2]         at [object Object].ElementArrayFinder.applyAction_ (C:\Users\amcinerney\AppData\Roaming\npm\node_modules\protractor\lib\element.js:380:21)
> [firefox #2]         at [object Object].ElementArrayFinder.(anonymous function) [as isDisplayed] (C:\Users\amcinerney\AppData\Roaming\npm\node_modules\protractor\lib\element.js:78:17)
> [firefox #2]         at [object Object].ElementFinder.(anonymous function) [as isDisplayed] (C:\Users\amcinerney\AppData\Roaming\npm\node_modules\protractor\lib\element.js:709:7)
> [firefox #2]         at FilesPage.OpenDropZone (C:\Newforma\Rosetta\rosettaweb\RosettaWeb.ProtractorTest\Common\PageObjects\Files.Page.js:191:25)
> [firefox #2]         at FilesPage.AddRandomFile (C:\Newforma\Rosetta\rosettaweb\RosettaWeb.ProtractorTest\Common\PageObjects\Files.Page.js:216:8)
> [firefox #2]         at Object.<anonymous> (C:\Newforma\Rosetta\rosettaweb\RosettaWeb.ProtractorTest\Files\Files.DeleteFiles.spec.js:41:21)
> [firefox #2]         at C:\Users\amcinerney\AppData\Roaming\npm\node_modules\protractor\node_modules\jasminewd2\index.js:96:23
> [firefox #2]         at new wrappedCtr (C:\Users\amcinerney\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\goog\base.js:2468:26)
> [firefox #2]         at controlFlowExecute (C:\Users\amcinerney\AppData\Roaming\npm\node_modules\protractor\node_modules\jasminewd2\index.js:82:18)
> [firefox #2]     From: Task: Run it("1270130, Delete button is shown when a file row is checked") in control flow
> [firefox #2]         at Object.<anonymous> (C:\Users\amcinerney\AppData\Roaming\npm\node_modules\protractor\node_modules\jasminewd2\index.js:81:14)
> [firefox #2]         at attemptAsync (C:\Users\amcinerney\AppData\Roaming\npm\node_modules\protractor\node_modules\jasmine\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:1916:24)
> [firefox #2]         at QueueRunner.run (C:\Users\amcinerney\AppData\Roaming\npm\node_modules\protractor\node_modules\jasmine\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:1871:9)
> [firefox #2]         at C:\Users\amcinerney\AppData\Roaming\npm\node_modules\protractor\node_modules\jasmine\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:1898:16
> [firefox #2]         at C:\Users\amcinerney\AppData\Roaming\npm\node_modules\protractor\node_modules\jasmine\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:1842:9
> [firefox #2]         at C:\Users\amcinerney\AppData\Roaming\npm\node_modules\protractor\node_modules\jasminewd2\index.js:18:5
> [firefox #2]         at goog.async.run.processWorkQueue (C:\Users\amcinerney\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\goog\async\run.js:124:15)
> [firefox #2]     From asynchronous test:
> [firefox #2]     Error
> [firefox #2]         at Suite.<anonymous> (C:\Newforma\Rosetta\rosettaweb\RosettaWeb.ProtractorTest\Files\Files.DeleteFiles.spec.js:38:2)
> [firefox #2]         at addSpecsToSuite (C:\Users\amcinerney\AppData\Roaming\npm\node_modules\protractor\node_modules\jasmine\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:833:25)
> [firefox #2]         at Env.describe (C:\Users\amcinerney\AppData\Roaming\npm\node_modules\protractor\node_modules\jasmine\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:802:7)
> [firefox #2]         at jasmineInterface.describe (C:\Users\amcinerney\AppData\Roaming\npm\node_modules\protractor\node_modules\jasmine\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:3375:18
> [firefox #2]         at Object.<anonymous> (C:\Newforma\Rosetta\rosettaweb\RosettaWeb.ProtractorTest\Files\Files.DeleteFiles.spec.js:8:1)

@amcinerney
Copy link
Author

Update: I was able to fix the issue, what I needed to do was ad an expected condition to wait for the element to be present in the DOM before doing the .isDisplay() check. For whatever reason firefox handles this type of scenario poorly compared to chrome. I'm not sure if this is something fixable or not, but I will let someone else close this ticket once they have read and can confirm this is acceptable behavior.

var uploadFileButton = element(by.id('uploadFile')); browser.wait(protractor.ExpectedConditions.presenceOf(this.uploadFileButton), 5000); uploadFileButton.isDisplayed().then(function(result){ if(!result){ // create a new folder and navigate into it }; });

@heathkit
Copy link
Contributor

Sounds like a bug in either Firefox or Selenium. If you have a chance, I'd be interested if earlier versions of Firefox show the same issue. Thanks.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants