sublime
sublime

Reputation: 4161

Selenium WebDriver Javascript : Modify element CSS

I'm writing automated tests with Selenium Javascript WebDriver. I'd like to know how I can modify CSS on the page.

http://code.google.com/p/selenium/wiki/WebDriverJs

So far, I'm able to get DOM elements, click them, or type text into input fields.

driver.findElement(webdriver.By.css("#myid"));
webElem.click();
webElem.sendKeys();

I'm stuck right now with a problem that one of the input field type is hidden. So when I try to do webElem.sendKeys() I get this Error:

"Element is not clickable at point"

I'd like to change the type of this input field from "hidden" to "text" so that I can call sendKeys on it. I couldn't find any documentation on how to do that.

Upvotes: 0

Views: 1818

Answers (1)

user3179064
user3179064

Reputation:

You can execute Javascript like this:

var webdriver = require('selenium-webdriver');
var driver = new webdriver
    .Builder()
    .withCapabilities(webdriver.Capabilities.chrome())
    .build();

driver.executeScript('/* document.getElementById etc. */');

However in principle, I agree with Arran in the comments above.

Upvotes: 1

Related Questions