I am using Java and Selenium to write tests for Chrome. I need to open the download page at one point so I used:
action.sendKeys(Keys.CONTROL + "j").build().perform();
but it does NOT open the page. then I added this line before it as I though it might work but it didn't:
WebElement body = wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//body[@id='body']")));
action.sendKeys(body, Keys.CONTROL + "j").build().perform();
The weird point is that
action.sendKeys(Keys.CONTROL + "a").build().perform();
Works!!
NOTE: I do not want to use Robot class as it will open the page on other browsers if the focus is not on the test target browser.
Try using like Below code, it is working perfectly at my end ...
I'd suggest not to go for chrome://downloads as this will not work in IE and FF but CTRL + j will work on all chrome, IE and FF.
Do you need to use the key binding? You could just navigate to the URL
chrome://downloads/
...Edit: Ofc, this is not the ideal solution for cross-browser compability. But definitely a good workaround for chrome.