vitalets / autotester

Chrome extension that allows to develop and run automation tests right in browser
MIT License
169 stars 25 forks source link

`elementIsEnabled` isn't working for me #2

Closed Semigradsky closed 7 years ago

Semigradsky commented 7 years ago

I am new in Selenium, maybe I'm doing smth wrong.

I try use elementIsEnabled from http://seleniumhq.github.io/selenium/docs/api/javascript/module/selenium-webdriver/lib/until.html:

    driver.get(URL.searchPage);
    driver.wait(until.elementLocated(CSS.searchFormOpenButton));

    const searchFormOpenButton = driver.findElement(CSS.searchFormOpenButton);
    driver.wait(until.elementIsEnabled(searchFormOpenButton));
    searchFormOpenButton.sendKeys(Key.ENTER);

    driver.sleep(2000);

Autotester says me:

WebDriverError: Unsupported route command: GET /session/loopback/element/197/enabled
    at Object.throwDecodedError (core/background/bundle.js:17123:12)
    at parseHttpResponse (core/background/bundle.js:16323:16)
    at doSend.then.response (core/background/bundle.js:16265:12)
From: Task: WebElement.isEnabled()
    at mixin.schedule (core/background/bundle.js:18207:18)
    at WebElementPromise.schedule_ (core/background/bundle.js:19616:26)
    at WebElementPromise.isEnabled (core/background/bundle.js:19917:18)
    at core/background/bundle.js:31623:21
    at core/background/bundle.js:18546:15
    at TaskQueue.execute_ (core/background/bundle.js:5807:15)
    at TaskQueue.executeNext_ (core/background/bundle.js:5790:22)
    at asyncRun (core/background/bundle.js:5707:26)
    at core/background/bundle.js:3715:8
From: Task: <anonymous>
    at pollCondition (core/background/bundle.js:5242:17)
    at core/background/bundle.js:5238:10
    at new ManagedPromise (core/background/bundle.js:4093:8)
    at core/background/bundle.js:5237:15
    at TaskQueue.execute_ (core/background/bundle.js:5807:15)
    at TaskQueue.executeNext_ (core/background/bundle.js:5790:22)
    at asyncRun (core/background/bundle.js:5660:28)
    at core/background/bundle.js:3715:8
From: Task: Waiting until element is enabled
    at ControlFlow.wait (core/background/bundle.js:5235:18)
    at mixin.wait (core/background/bundle.js:18542:30)
    at Context.<anonymous> (runtime/new_file_1:25:12)
    at core/background/bundle.js:33289:20
    at new ManagedPromise (core/background/bundle.js:4093:8)
    at controlFlowExecute (core/background/bundle.js:33274:15)
    at TaskQueue.execute_ (core/background/bundle.js:5807:15)
    at TaskQueue.executeNext_ (core/background/bundle.js:5790:22)
    at asyncRun (core/background/bundle.js:5707:26)
    at core/background/bundle.js:3715:8
From: Task: new_file_1 should pass
    at Context.ret (core/background/bundle.js:33273:11)
vitalets commented 7 years ago

Hi Dmitry,

everything you are doing is right. Currently not all webdriver routes are supported (what is supported is listed here)

But we can temporary overcome it by getting enabled property directly via executeScript:

const enabledPromise = driver.executeScript(el => !el.disabled, searchFormOpenButton);

And using with driver.wait:

driver.wait(() => {
  return driver.executeScript(el => !el.disabled, searchFormOpenButton);
});
vitalets commented 7 years ago

Added this error to FAQ.