简体   繁体   中英

Selenium.Key Action with Java Webdriver

Java WebDriver most recent release firefoxbrowser is the only one I'm coding for. this is for automation not testing.

Disregarding the lack of headers and such. I simply am attempting to select a text box. then send a ctrl-home so that the cursor is placed at the beginning of the box. then based on some previously identified criteria it is supposed to send the delete command x amount of times. Well it selects the text box, and I can see the cursor flicker around, but it does not appear to be jumping to the top home position, and doesn't appear to be deleting anything. Obviously my first concern is the home position.

int a = 0;
int del = dateline_name.length();
del = del + 2 ;                                 
                driver.findElement(By.id("id_story")).click();
                    Actions action = new Actions(driver);
                    action.keyDown(Keys.CONTROL).sendKeys(Keys.HOME).keyUp(Keys.CONTROL).perform();
                        while (a <= del)
                            {
                            action.sendKeys(Keys.DELETE).perform();
                            a++;
                            }   

I have tried the same with Firefox and observed that if there is no keyUp(Keys.CONTROL) in the action, it works. Please try removing the keyUp from the action sequence. Thanks.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM