question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"uncheckOption" not working in Webdriver helper

See original GitHub issue

What are you trying to achieve?

Uncheck checkbox using WebDriver.

What do you get instead?

After execution of uncheckOption command checkbox is not unchecked.

$ npx codeceptjs run-multiple all:chrome -c ./codecept/codeceptWebdriver.conf.js --steps
[1.all:chrome] CodeceptJS v2.1.2
[1.all:chrome] Using test root "C:\Users\evgenii.mikhailishin\IdeaProjects\parsers\atf-web-poc\atf-web-poc\CodeceptJS-Allure\codecept"

[1.all:chrome] checkboxes --
[1.all:chrome]   1
[1.all:chrome]     I am on page "https://www.w3schools.com/tags/tryit.asp?filename=tryhtml5_input_type_checkbox"
[1.all:chrome]     I resize window 1536, 824
[1.all:chrome]     I switch to {"id":"iframeResult"}
[1.all:chrome]     I check option {"name":"vehicle1"}
[1.all:chrome]     I uncheck option {"name":"vehicle3"}
[1.all:chrome]     I click {"xpath":"//input[@value='Submit']"}
[1.all:chrome]     I see text equals "vehicle1=Bike ", {"css":".w3-large"}
[1.all:chrome]   × FAILED in 5321ms
[1.all:chrome]

[1.all:chrome] -- FAILURES:

  1) checkboxes
       1:
     expected element [object Object] "vehicle1=Bike " to equal "vehicle1=Bike&vehicle3=Boat "

  Scenario Steps:

  - I.seeTextEquals("vehicle1=Bike ", {"css":".w3-large"}) at Test.Scenario (tests\converted\checkboxes check uncheck verify text.js:12:6)
  - I.click({"xpath":"//input[@value='Submit']"}) at Test.Scenario (tests\converted\checkboxes check uncheck verify text.js:11:6)
  - I.uncheckOption({"name":"vehicle3"}) at Test.Scenario (tests\converted\checkboxes check uncheck verify text.js:8:6)
  - I.checkOption({"name":"vehicle1"}) at Test.Scenario (tests\converted\checkboxes check uncheck verify text.js:7:6)
  - I.switchTo({"id":"iframeResult"}) at Test.Scenario (tests\converted\checkboxes check uncheck verify text.js:6:6)
  - I.resizeWindow(1536, 824) at Test.Scenario (tests\converted\checkboxes check uncheck verify text.js:5:6)
  - I.amOnPage("https://www.w3schools.com/tags/tryit.asp?filename=tryhtml5_input_type_checkbox") at Test.Scenario (tests\converted\checkboxes check uncheck verify text.js:4:6)



  Run with --verbose flag to see NodeJS stacktrace


[1.all:chrome]   FAIL  | 0 passed, 1 failed   // 8s

Provide test source code if related

Feature("checkboxes");

Scenario("1", async (I) => {
   I.amOnPage("https://www.w3schools.com/tags/tryit.asp?filename=tryhtml5_input_type_checkbox");
   I.resizeWindow(1536,824);
   I.switchTo({id: 'iframeResult'});
   I.checkOption({name:"vehicle1"});
   I.uncheckOption({name:"vehicle3"});

   //pause();
   I.click({xpath:"//input[@value='Submit']"});   
   I.seeTextEquals("vehicle1=Bike ",{css:".w3-large"});
});

Details

  • CodeceptJS version: v2.1.2
  • NodeJS Version: v11.3.0
  • Operating System: Windows 10 x64
  • WebDriverIO: 5.8.4
  • Configuration file:
exports.config = {
  tests: '../tests/converted/*.js',
  output: '../output',
  helpers: {
    Webdriver: {
      url: '127.0.0.1:9000',
      browser: 'chrome',
    }
  },
  "multiple": {
    "all": {
      "browsers": ["chrome", "firefox"]
    },
  },
  include: {
    I: '../steps_file.js'
  },
  bootstrap: null,
  "plugins": {
    "allure": {},
    "stepByStepReport": {
      "enabled": true,
      "deleteSuccessful": true,
      //disabled screenshot on "click" commands because of screenshot fail when JS alert pops up
      "ignoreSteps": ["assertAlert*", "choose-*", "click*", "seeInPopup*", "wait*", "grab*"],
      "screenshotsForAllureReport": true
    },
    "autoDelay": {
      "enabled": false,
      "delayBefore": 10000,
      "delayAfter": 100
    }
  },
  mocha: {},
  name: 'Codecept-Allure POC'
}

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:14 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
tsuemuracommented, May 22, 2019
1reaction
PeterNgTrcommented, May 17, 2019

@evgeniy-mh please try with following code, I tested and worked properly on my machine

Scenario('Uncheck option test', (I) => {
  I.amOnPage('https://www.w3schools.com/tags/tryit.asp?filename=tryhtml5_input_type_checkbox');
  within({ frame: "#iframeResult" }, () => {
    I.checkOption('form input[name="vehicle1"]');
    I.uncheckOption('form input[name="vehicle1"]');
    I.checkOption('form input[name="vehicle3"]');
  });
});
Read more comments on GitHub >

github_iconTop Results From Across the Web

"uncheckOption" not working in Webdriver helper · Issue #1655
After execution of uncheckOption command checkbox is not unchecked. $ npx codeceptjs run-multiple all:chrome -c ./codecept/codeceptWebdriver.
Read more >
WebDriver - CodeceptJS
WebDriver helper which wraps webdriverio (opens new window) library to manipulate browser using Selenium WebDriver or PhantomJS. WebDriver ...
Read more >
WebDriver - Codeception - Documentation
Locates element using available Codeception locator types: XPath; CSS; Strict Locator. Use it in Helpers or GroupObject or Extension classes: <?php $els ...
Read more >
WebDriver - CodeceptJS
WebDriver helper which wraps webdriverio library to manipulate browser using Selenium WebDriver or PhantomJS. WebDriver requires Selenium Server and ...
Read more >
Codeception with Webdriver $I->fillField not working although ...
Finally found an answer - there was some unknown hidden element which matched the same selector and this element caused an Exception:.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found