Whenever I run my tests on a Linux machine, I encounter an issue with the way text is typed using the following code snippet:
visibleElement.clear();
visibleElement.sendKeys("I am running on linux machine");
Instead of typing the text correctly as expected, various permutations like "on linux machine I am running", "running on linux machine I am" etc appear in the UI.
To address this issue, I resorted to using JavaScript:
JavascriptExecutor jse = (JavascriptExecutor)driver;
jse.executeScript("arguments[0].value='I am running on linux machine';", visibleElement);
While this successfully types the text in the field, it disables the Save
button which should actually be enabled. Interestingly, when I use sendKeys
, the button is enabled.
I am seeking assistance in understanding why the JavaScript approach behaves differently and how to rectify it to ensure both functionalities work seamlessly without relying on hitting tab to enable the button, as that is not a viable solution for my scenario.