0

Seem to be receiving the following exception:

element not visible
running chrome
Error: An element command could not be completed because the element is not visible on the page.
    at elementIdClick("0.12980231457632274-1") - click.js:20:22

My test us as followed:

    beforeEach(function() {
      browser.url("https://www.google.com");
    })
    describe('Test Google Homepage', function() {
        it('Should be able to click on im feeling lucky button', function(done) {
          browser.click('(//input)[7]');
    });
});

It seems the xpath is throwing the exception above even when adding a browser pause, any ideas why im receiving the exception?

SamP
  • 417
  • 5
  • 24
  • 1
    zfrisch im using an xpath selector which locators the 'im feeling lucky' button. – SamP Aug 31 '18 at 14:53
  • are you adding enough wait time before locating this element? Also, I would recommend to use locators with reference to its attributes. For example: //input[@value=\"I'm Feeling Lucky\"] – theGuy Aug 31 '18 at 17:20
  • I tried adding a pause but seems the same issue was present :/ my intentions was to use the number 7 as part of a loop to click on multiple button instances but unable to narrow the issue down; especially when the same locator works within the browser itself. – SamP Aug 31 '18 at 18:02
  • I don't know much about javascript with selenium but can you make sure if your syntax is correct. Shouldn't it be browser.click("(//input)[7]"); instead of single quotes? – theGuy Aug 31 '18 at 18:25
  • Also tried the following still dosnt work :( – SamP Aug 31 '18 at 19:08
  • Can you share on which browser you are trying + version of it and all the versions of npmModules that you are using. Try to get the browserDriver version as well. PS: I want to add this as comment but i do not have 50 reputation. – Naveen Thiyagarajan Sep 01 '18 at 05:12
  • I'm using the latest version of Chrome and mom modules. – SamP Sep 01 '18 at 09:16
  • Based on your previous comments... so in case you want to iterate through all the elements and click on multiple elements then follow the below link: https://stackoverflow.com/questions/51255595/webdriverio-select-using-elements-index/51259227#51259227 – Naveen Thiyagarajan Sep 01 '18 at 12:54
  • using wdio i was able to successfully perform click using xpath `browser.click('(//input)[7]');` – Naveen Thiyagarajan Sep 01 '18 at 13:01
  • thanks Naveen, what npm dependency versions are you using? – SamP Sep 01 '18 at 15:25
  • here are the versions: "webdriverio": "^4.12.0" "wdio-selenium-standalone-service": "0.0.10", "wdio-mocha-framework": "^0.5.13", Just a note: I assume the issue might be related to chromeVersion with the chromeDriver version ... please double check that. – Naveen Thiyagarajan Sep 01 '18 at 17:55

1 Answers1

1

Because you shouldn't be using xpath?

Try: browser('[aria-label="I\'m Feeling Lucky"]').click()

Also it's much better to use named things rather than counting on the order of things in the page.

Tom
  • 43,583
  • 4
  • 41
  • 61
  • Thanks for the comment Tom, what if I intend to use the indexed number 7 as part of a loop to click on multiple elements by referencing the xpath? – SamP Sep 01 '18 at 09:15