我正在尝试将属性设置为滑块。我正在使用javascript进行自动化,目前已经尝试了以下代码,
it('should pan plots when you click and drag', function(done) {
driver.sleep(2000);
driver.findElement(webdriver.By.css('._md-slider-wrapper')).click().then(function(){
driver.findElement(webdriver.By.css('._md-thumb-container')).SetAttribute("style", "left: 22px");
done();
});
但它不起作用。我也尝试过将元素传递给函数,然后尝试设置属性,但它也没有起作用。我基本上是试图将值设置为滑块。
最佳答案
尝试这个:
driver.executeScript("document.querySelector('._md-thumb-container').setAttribute('style', 'left: 22px'");