SeleniumHQ / selenium

A browser automation framework and ecosystem.
https://selenium.dev
Apache License 2.0
30.5k stars 8.15k forks source link

[🐛 Bug]: Not able to open the url in the new tab using Actions Class #14586

Open SharmaSalil opened 3 hours ago

SharmaSalil commented 3 hours ago

What happened?

WebDriver driver = new ChromeDriver();

    driver.get("https://rahulshettyacademy.com/AutomationPractice/");

    driver.manage().window().maximize();

    WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(20));

    System.out.println("Click on the Url to open in New Tab");

    wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//a[@class='blinkingText']")));

    Actions action = new Actions(driver);

    WebElement link = driver.findElement(By.xpath("//a[@class='blinkingText']"));

    action.keyDown(Keys.CONTROL).moveToElement(link).click().build().perform();

    wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//p[contains(@class, 'red')]//a")));

    driver.quit();

    This is not working !! It should open the link in the new tab but i guess it is clicking contextClick()

How can we reproduce the issue?

WebElement link = driver.findElement(By.xpath("//a[@class='blinkingText']"));
action.keyDown(Keys.CONTROL).moveToElement(link).click().build().perform(); 

By running this code

Relevant log output

No Logs !!

Operating System

mac11.7.10

Selenium version

4.25.0

What are the browser(s) and version(s) where you see this issue?

128.0.6613.139

What are the browser driver(s) and version(s) where you see this issue?

selenium 4.25

Are you using Selenium Grid?

No response

github-actions[bot] commented 3 hours ago

@SharmaSalil, thank you for creating this issue. We will troubleshoot it as soon as we can.


Info for maintainers

Triage this issue by using labels.

If information is missing, add a helpful comment and then I-issue-template label.

If the issue is a question, add the I-question label.

If the issue is valid but there is no time to troubleshoot it, consider adding the help wanted label.

If the issue requires changes or fixes from an external project (e.g., ChromeDriver, GeckoDriver, MSEdgeDriver, W3C), add the applicable G-* label, and it will provide the correct link and auto-close the issue.

After troubleshooting the issue, please add the R-awaiting answer label.

Thank you!