Reputation:
driver.SwitchTo().Frame("contentFrame");
IWebElement str = driver.FindElement(By.XPath("//*[@id='dvCustomDateRange']"));
I need to change the style attribute from style="display: none;" to style="display: block;".
This is the element:
<div id="dvCustomDateRange" tabindex="0" class="filters hidden inline-block inlineChilds NoPrint width100 marginBt7" style="display: block;">
any idea how to do this using Selenium? Im try getAttribute and getCssValue methods to change value but without result.
Upvotes: 6
Views: 9523
Reputation: 344
executeScript() will do the trick:
driver.executeScript("arguments[0].style='display: block;'",element);
Upvotes: 0
Reputation: 9058
You will have to use javascript executor to set a css attribute value.
IJavaScriptExecutor js = driver as IJavaScriptExecutor;
js.executeScript("arguments[0].style='display: block;'", element);
Upvotes: 9