Selenium Webdriver : How to delete an open email from Gmail using selenium webdriver
First you need Mouse hover
to groupElement
:
//div[@class='iH bzn']//div[@class='G-tF']//div[2][@class='G-Ni G-aE J-J5-Ji']
The delete icon need trigger from another element to visible:
//add some wait hereWebElement groupElement = driver.findElement(By.xpath("//div[@class='iH bzn']//div[@class='G-tF']//div[2][@class='G-Ni G-aE J-J5-Ji']"));Actions action = new Actions(driver);action.moveToElement(groupElement).build().perform();driver.findElement(By.xpath("//div[@aria-label='Delete']//div[@class='asa']")).click();
Following import:
import org.openqa.selenium.interactions.Actions;
Javascript code which through you can delete open email from Gmail.
let down = new MouseEvent('mousedown');let up = new MouseEvent('mouseup');let elem = document.getElementsByClassName('nX')[0];elem.dispatchEvent(down);elem.dispatchEvent(up);
Thanks.