Selenium: delete contents from a textbox

后端 未结 5 1307
囚心锁ツ
囚心锁ツ 2021-02-07 11:41

Through selenium. how to delete contents from textbox.

I have to delete the last 2 characters from text box using selenium command.

Ex.ABCD to AB.

相关标签:
5条回答
  • 2021-02-07 12:12

    For firefox, the backspace event works only if you setCursorPosition at the END of the text in the textarea, otherwise the typeKeys event will type at the begining of the text.

    0 讨论(0)
  • 2021-02-07 12:18

    Click onto it, hit end key and backspace twice

    0 讨论(0)
  • 2021-02-07 12:19

    Try this -

    selenium.type("text_box_object", "ABCD");
    selenium.typeKeys("text_box_object", "\b");
    selenium.typeKeys("text_box_object", "\b");
    
    0 讨论(0)
  • 2021-02-07 12:24

    Read the current value and store it as a variable. Then 'Type' out the value that you want in the target field (using a substring of the stored value).

    0 讨论(0)
  • 2021-02-07 12:33

    The keyPress event of selenium can be helpful:

    selenium.sendKeys("text1", "ABCD");
    selenium.sendKeys("text1", "\b");
    selenium.sendKeys("text1", "\b");
    

    This will Click Backspace key twice.

    0 讨论(0)
提交回复
热议问题