简体   繁体   中英

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.

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.

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