0

I am testing a non-angular (javascript and HTML) site with protractor and selenium. I want to clear the input. I have used below commands

browser.driver.findElement(by.id('txtname')).clear();
browser.driver.findElement(by.id('txtEditGuestFname')).sendKeys(Keys.chord(Keys.CONTROL, "a"), "1234");

since i can not use angular syntax both the codes doesn't work to me.

Any other idea how to clear the input with simple javascript protractor supporting code?

alecxe
  • 462,703
  • 120
  • 1,088
  • 1,195
user3369120
  • 89
  • 1
  • 13
  • Can you send keys only? Without clearing input? – kotoj Jun 20 '16 at 19:48
  • Might help you with using protractor on a non-angular page: http://stackoverflow.com/a/23198865/3561995 – SteamDev Jun 20 '16 at 20:33
  • .sendKeys(' ') append the text to textbox not replace it. I want to clear the pre filled text and then want to enter my own text with .sendKeys() – user3369120 Jun 21 '16 at 09:28
  • Um, is this really from your code? If so, there's a problem. the first line clears one text field, and the second line calls sendKeys to a completely different text field. If you want to clear first, you need to clear the same one you're going to sendKeys to. – Breaks Software Jun 21 '16 at 12:00
  • the code i have sent is just an example (i know the text fields are different ). what i meant is i have used both the technique but it doesn't work. reason is my site is non-angular and those 2 codes are angular syntax. – user3369120 Jun 21 '16 at 17:14
  • Those 2 lines of code are not specific to angular or protractor, they are selenium webdriver syntax. They will work regardless of your site being angular. – martin770 Jun 23 '16 at 17:19
  • i know those syntax are for angular, how can i clear a input in non-angular site? – user3369120 Jun 29 '16 at 07:13

0 Answers0