I am using Selenium WebdriverJS (NOT Java selenium and NOT Webdriver.io!), which has horrible documentation for beginners. I need to right click an element and move down to "save as", then .sendKeys()
then Enter
since this seems to be the only way to save an image from a web page without a full page screenshot.
I am trying to implement the following Java solution in Javascript but no dice:
Here a few of many different versions I tried. All give me errors relating to 'Keys' or 'ARROW_DOWN' or 'DOWN'.
var webdriver = require('selenium-webdriver'),
By = webdriver.By,
until = webdriver.until,
button = webdriver.Button,
promise = webdriver.promise;
fs = require('fs');
//Generate browser
var driver = new webdriver.Builder()
.forBrowser('chrome')
.build();
/******* Begin Tests*******/
//Begin test from login page
driver.manage().window().maximize();
driver.get('https://www.google.com/ncr');
driver.sleep(2000);
/*********** NONE OF THESE WORK ***********/
//Actions is not defined
var GoogleLogoImg = driver.findElement(By.css('#hplogo')).then(function() {
driver.Actions.contextClick(GoogleLogoImg)
.sendKeys(Keys.ARROW_DOWN)
.sendKeys(Keys.ARROW_DOWN)
.sendKeys(Keys.RETURN)
.perform();
})
//Keys is not defined
var GoogleLogoImg = driver.findElement(By.css('#hplogo')).then(function() {
driver.actions().click(button.RIGHT).perform().then(function(){
driver.sendKeys(Keys.ENTER);
});
});
//Not a modifier key
var GoogleLogoImg = driver.findElement(By.css('#hplogo')).then(function() {
driver.actions().click(button.RIGHT).perform().then(function(){
new webdriver.ActionSequence(driver).
keyDown(webdriver.Key.ARROW_DOWN). // <-- 'Not a modifier key'
keyUp(webdriver.Key.ARROW_DOWN).
perform();
});
});
//Not a modifer key
var GoogleLogoImg = driver.findElement(By.css('#hplogo')).then(function() {
driver.actions().click(button.RIGHT).perform().then(function(){
new webdriver.ActionSequence(driver).
keyDown(webdriver.Key.DOWN). // <-- 'Not a modifier key'
keyUp(webdriver.Key.DOWN).
perform();
});
});
Keys is not defined
, hmm how aboutdriver.Keys.enter
?