I have try to press the delete key using below command but it doesn't reflect anything!
element = driver.findElement(By.cssSelector((#DeleteThis)));
element.sendKeys(Keys.DELETE);
I have try to press the delete key using below command but it doesn't reflect anything!
element = driver.findElement(By.cssSelector((#DeleteThis)));
element.sendKeys(Keys.DELETE);
You need to build an action and the send it, the send keys is bound to actions not elements, example :
Actions action = new Actions(yourDriver);
action.sendKeys(Keys.DELETE).build().perform();
This will simulate pressing "delete" from your keyboard
In case you have the element delete (as from your example) and you need to click it, you just perfomr the click action on the element.
Ok to do so, you need to use the delete command, kindly use the below code to perform the same. If it doesn't work first try to select it, as mentioned below.
To delete it use below code:
WebElement ele = driver.findElement(By.cssSelector("#DeleteThis"));
ele.sendKeys(Keys.chord(Keys.DELETE));
Have you tried to first select it and then delete it?
Use below code, it will first select the element and then delete it.
ele.sendKeys(Keys.chord(Keys.CONTROL, "a"), Keys.DELETE);