3

My code logs into mediawiki's beta site, goes to the Preferences page and attempts to click on a button at the bottom of the page.

I am trying to use scroll() to achieve this since, running only .click() will result in an error, similar to the one below. The problem is that .scroll() doesn't seem to have any effect.

I'm using version 4 of WebdriverIO.

What I've tried:

  1. I've tried this test with just elem.click(), without any scrolling and this resulted in a message similar to the one below where the element is not clickable.

  2. When I run the code without elem.click(), the test passes, but I do not see the page scroll at all (I add browser.pause( 9000); to the end to check).

  3. When I run .scroll() and pass it values, such as elem.scroll(0,500), the page does scroll down, but not enough to see the actual element.

  4. I've tried .moveToObject() which seems to scroll down the page, but not enough to see/interact with the element. I've also tried passing values to this, but it did not work.


it( 'should demonstrate the scroll command on the Preferences Page ', function () {
    // login 
    browser.url( 'https://en.wikipedia.beta.wmflabs.org/w/index.php?title=Special:UserLogin&returnto=Main+Page' );
    var loginName = $( '#wpName1' );
    var loginPass = $( '#wpPassword1' );
    var loginBtn = $( '#wpLoginAttempt' );
    loginName.setValue( 'Ephemeraltest' );
    loginPass.setValue( 'vagrant123' );
    loginBtn.click();

    // click button at bottom of preferences page
    browser.url( 'https://en.wikipedia.beta.wmflabs.org/wiki/Special:Preferences' );
    var elem = $( '#ooui-php-41' );

    elem.scroll();
    elem.click();

});

When I run the code, this error is reported:

unknown error: Element ... is not clickable at point (602, 571). Other element would receive the click: ... running chrome Error: An unknown server-side error occurred while processing the command. at elementIdClick("0.7032716938931156-1") - click.js:20:22

iamdanchiv
  • 3,828
  • 4
  • 32
  • 40

1 Answers1

3

Have you tried the scrollIntoView? If not try this: selector here would be '#ooui-php-41'

        browser.execute(elem => elem.scrollIntoView(), browser.element(selector).value);
  • They are using webdriverio version 4. Looks like scrollIntoView is available only in version 5 (https://webdriver.io/docs/api/element/scrollIntoView.html), not version 4 (http://v4.webdriver.io/api.html). – Željko Filipin Jul 15 '19 at 12:50
  • 1
    Hi, The above example is written using `browser.execute()`(javascript executor). This command works in `v4`(because we are using it). – Naveen Thiyagarajan Jul 15 '19 at 14:17