How to preserve the character sequence sent through SendKeys() method through Selenium and C#

一曲冷凌霜 提交于 2019-12-02 06:25:10

It would be tough to predict the actual issue behind the non perseverance of the sequential order of the character sequence sent through SendKeys() method in absence of the relevant HTML.

However, in case the AUT (Application Under Test) is JavaScript, Angular or ReactJS based, as per best practices you need to induce WebDriverWait for the desired element to be clickable, then you need to invoke Clear() method and finally invoke SendKeys() method as follows:

  • C#:

    IWebElement textBoxElement = new WebDriverWait(driver, TimeSpan.FromSeconds(10)).Until(ExpectedConditions.ElementToBeClickable(By.XPath("xpath_of_HOME_key_button")));
    textBoxElement.Click();
    textBoxElement.Clear();
    textBoxElement.SendKeys("1234");
    
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!