I'm trying to perform shortcut cmd (ctrl) + shift + u in selenide to open WCAG extension. However chromium ignores it totally. If I leave window open, I have to fiddle with it (eg. minimize + maximize) to be able to pass that shortcut even manually. Eventually it works, but just manually. I've also tried other shortcuts like copy & paste from text field to another one...
Anyone with similar problem? how did you avoid it?
Link to github repository: https://github.com/1azyman/selenide-wcag-sample
Sample code:
package com.example;
import com.codeborne.selenide.Configuration;
import com.codeborne.selenide.WebDriverRunner;
import org.openqa.selenium.Keys;
import org.openqa.selenium.Platform;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.interactions.Actions;
import java.io.File;
import static com.codeborne.selenide.Selenide.open;
public class Main {
public static void main(String[] args) throws Exception {
Configuration.baseUrl = "https://google.com";
// wave extension
// https://chrome.google.com/webstore/detail/wave-evaluation-tool/jbbplnpkjmmeebjpijfedlgcdilocofh
Configuration.browserCapabilities = new ChromeOptions()
.addExtensions(new File("src/main/resources/wave.crx"));
open("/");
WebDriver driver = WebDriverRunner.getWebDriver();
Keys cmdCtrl = Platform.getCurrent().is(Platform.MAC) ? Keys.COMMAND : Keys.CONTROL;
// shortcut to open wave (cmd+shift+u)
// String wave = Keys.chord(cmdCtrl, Keys.SHIFT, "u");
// new Actions(driver)
// .sendKeys(wave)
// .perform();
new Actions(driver)
.keyDown(cmdCtrl)
.keyDown(Keys.SHIFT)
.sendKeys("u")
.keyUp(Keys.SHIFT)
.keyUp(cmdCtrl)
.perform();
Thread.sleep(20_000L);
}
}
Selenide actions doesn't equal native user keypresses. So, not all actions (especially related to extension shortcuts) would work as expected.
However, as a workaround you can use
Robot
class with Selenide. Be aware that it's execution will intercept your current focus, as far as it executes shortcut in OS System context.