简体   繁体   中英

Selenium Java on Mac - Pressing Command Button + Click // Or Pressing middle mouse button

Hello everybody: Here I have the next situation:

I want to click an element with Mac OS pressing Command button + click.

This is the code I have:

Actions action = new Actions(driver);

        //View full profile link
        WebElement fprofile = driver.findElement(By.className("something"));

        action.keyDown(Keys.COMMAND)
                .click(fprofile)
                .keyUp(Keys.COMMAND)
                .build()
                .perform();

It seems it's not working.

By other hand, I try to make a click with mouse middle button, but I cannot find how to do that.

The solution to the part of keep pressing the Command button on Mac and click is the next:

action.keyDown(Keys.COMMAND)
                .click(WebElement)
                .keyUp(Keys.COMMAND)
                .build()
                .perform();

By other side, I cannot discover how to make a click over an element with the mouse middle button.

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