Created
September 28, 2020 13:39
-
-
Save muditlambda/97e20792c5271f28d8528cefec70f879 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import static org.testng.Assert.assertEquals; | |
import java.util.concurrent.TimeUnit; | |
import org.openqa.selenium.By; | |
import org.openqa.selenium.WebDriver; | |
import org.openqa.selenium.WebElement; | |
import org.openqa.selenium.chrome.ChromeDriver; | |
import org.openqa.selenium.interactions.Actions; | |
public class clickDemo { | |
public static void main(String[] args) { | |
// specify the driver location | |
System.setProperty("webdriver.chrome.driver", "C:\\Users\\Shalini\\Downloads\\Driver\\chromedriver.exe"); | |
// instantiate the driver | |
WebDriver driver = new ChromeDriver(); | |
//specify the URL of the website | |
driver.get("https://www.amazon.in/"); | |
//maximise the window | |
driver.manage().window().maximize(); | |
WebElement element = driver.findElement(By.xpath("//*[@id=\"nav-xshop\"]/a[1]")); | |
Actions action = new Actions(driver); | |
action.doubleClick(element).build().perform(); | |
assertEquals(driver.getTitle(), "Mobile Phones: Buy New Mobiles Online at Best Prices in India | Buy Cell Phones Online - Amazon.in"); | |
driver.manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS); | |
action.contextClick().build().perform(); | |
driver.quit(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment