{"action":"created","issue":{"url":"https://api.github.com/repos/webdriverio/webdriverio/issues/1791","repository_url":"https://api.github.com/repos/webdriverio/webdriverio","labels_url":"https://api.github.com/repos/webdriverio/webdriverio/issues/1791/labels{/name}","comments_url":"https://api.github.com/repos/webdriverio/webdriverio/issues/1791/comments","events_url":"https://api.github.com/repos/webdriverio/webdriverio/issues/1791/events","html_url":"https://github.com/webdriverio/webdriverio/issues/1791","id":197782866,"number":1791,"title":"`browser.keys()` ignore the current caret position","user":{"login":"AlexandreBonneau","id":7248877,"avatar_url":"https://avatars.githubusercontent.com/u/7248877?v=3","gravatar_id":"","url":"https://api.github.com/users/AlexandreBonneau","html_url":"https://github.com/AlexandreBonneau","followers_url":"https://api.github.com/users/AlexandreBonneau/followers","following_url":"https://api.github.com/users/AlexandreBonneau/following{/other_user}","gists_url":"https://api.github.com/users/AlexandreBonneau/gists{/gist_id}","starred_url":"https://api.github.com/users/AlexandreBonneau/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AlexandreBonneau/subscriptions","organizations_url":"https://api.github.com/users/AlexandreBonneau/orgs","repos_url":"https://api.github.com/users/AlexandreBonneau/repos","events_url":"https://api.github.com/users/AlexandreBonneau/events{/privacy}","received_events_url":"https://api.github.com/users/AlexandreBonneau/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2016-12-28T01:51:36Z","updated_at":"2016-12-29T20:06:11Z","closed_at":"2016-12-28T13:25:16Z","body":"## The problem\r\n\r\nI'm trying to achieve a seemingly very simple thing :\r\n1. Select an input\r\n2. Set the caret position inside that input\r\n3. Enter some numbers\r\n4. Verify the new caret position, as well as the input value\r\n\r\nTo do this, I created this test : [The html + buggy.spec.js](http://codepen.io/AnotherLinuxUser/pen/xRoVvX?editors=1010)\r\n\r\nUnfortunately, whenever `browser.keys(selectors.input0, ['123']);` is called, the caret position is reset to its default *on-the-far-right-of-the-input-value* place, which is really annoying, to say the least.\r\n\r\nI think that `keys()` should not change the caret position, and just manage...key inputs. Or perhaps I'm doing something very wrong here?\r\n\r\n## Environment\r\n* WebdriverIO version: 4.5.2\r\n* Node.js version: 4.6.1\r\n* [Standalone mode or wdio testrunner](http://webdriver.io/guide/getstarted/modes.html): wdio\r\n* if wdio testrunner, running synchronous or asynchronous tests: synchronous\r\n* Additional wdio packages used (if applicable): `wdio`, `wdio-dot-reporter` and `wdio-jasmine-framework`\r\n\r\n## Link to Selenium/WebdriverIO logs\r\nhttps://gist.github.com/AlexandreBonneau/7c2d39056eee8f457bdd8ac140b1d294\r\n\r\n## Code To Reproduce Issue\r\nwdio.conf.js : https://gist.github.com/anonymous/8a6f2dd7565f8e860a96408558c03928\r\n\r\n\r\nNote : commenting out the line 135 `browser.keys(selectors.input0, ['123']); ` does not move the caret to the far right of the input anymore, but then, how to enter numbers?\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/webdriverio/webdriverio/issues/comments/269685797","html_url":"https://github.com/webdriverio/webdriverio/issues/1791#issuecomment-269685797","issue_url":"https://api.github.com/repos/webdriverio/webdriverio/issues/1791","id":269685797,"user":{"login":"AlexandreBonneau","id":7248877,"avatar_url":"https://avatars.githubusercontent.com/u/7248877?v=3","gravatar_id":"","url":"https://api.github.com/users/AlexandreBonneau","html_url":"https://github.com/AlexandreBonneau","followers_url":"https://api.github.com/users/AlexandreBonneau/followers","following_url":"https://api.github.com/users/AlexandreBonneau/following{/other_user}","gists_url":"https://api.github.com/users/AlexandreBonneau/gists{/gist_id}","starred_url":"https://api.github.com/users/AlexandreBonneau/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AlexandreBonneau/subscriptions","organizations_url":"https://api.github.com/users/AlexandreBonneau/orgs","repos_url":"https://api.github.com/users/AlexandreBonneau/repos","events_url":"https://api.github.com/users/AlexandreBonneau/events{/privacy}","received_events_url":"https://api.github.com/users/AlexandreBonneau/received_events","type":"User","site_admin":false},"created_at":"2016-12-29T20:06:10Z","updated_at":"2016-12-29T20:06:10Z","body":"Thanks for you answer @christian-bromann.\r\n\r\nMy use case is that being one of the `autoNumeric` maintener, I'd like to setup user interaction testing since those interactions are the core of autoNumeric features.\r\n\r\n[autoNumeric](https://github.com/BobKnothe/autoNumeric) is a library that allows a user to enter some numbers in an input, and after each key stroke, the input value and caret position is updated on-the-fly to make it looks like a well-formatted currency.\r\n\r\nRight now, I have unit testing [setup](https://github.com/BobKnothe/autoNumeric/blob/next/test/unit/autoNumeric.spec.js) with Jasmine, and this works great to test *internal* functions, or when I want to test if the whole input gets [formatted correctly](https://github.com/BobKnothe/autoNumeric/blob/next/test/unit/autoNumeric.spec.js#L490), but the core feature of autoNumeric is the input interactions, and I need to test things like :\r\n1. Set the input value to the number `123456.78` with `input.autoNumeric('set', 123456.78)`\r\n2. Check that the input value and caret position is now `123,456.78|` ('|' symbolizing the caret position)\r\n3. Move the caret to `123,|456.78`\r\n4. Input the characters `'0'`, `'7'`, `'a'`, `'b'` and `'6'`\r\n5. Check that the input value and caret position is now `123,076|,456.78`\r\n\r\nSince we manage a **lot** of small user experience features, this kind of test is a must-have to make sure we are not introducing regression bugs when hacking the code.\r\n\r\nAnother simple example :\r\n1. Set the input value to the number `123456.78` with `input.autoNumeric('set', 123456.78)`\r\n2. Check that the input value and caret position is now `123,456.78|`\r\n3. Move the caret to `123,4|56.78`\r\n4. Input the characters `ArrowLeft` once\r\n5. Check that the input value and caret position is now `123|,456.78`\r\n\r\nThis is the kind of test I'm struggling to create right now.\r\n\r\nAs you can see in the link I [pasted](http://codepen.io/AnotherLinuxUser/pen/xRoVvX?editors=1010) in the initial post, I managed to retrieve the caret position from within the webdriver.io test file, but I had two problems :\r\n- first I need to redeclare my helper function (like `myGetCaretPosition`) in each `browser.execute` block, which I do not understand why and is not DRY, and\r\n- secondly and more importantly, entering keys via webdriver.io moves the cusor to the far right so all my tests are broken and impossible to execute."}}
{"actor":{"display_login":"AlexandreBonneau"}}