简体   繁体   中英

Disable JavaScript in Chrome with rendered page with C# & Selenium WebDriver

I am running my test in Visual Studio 10, with C# and Selenium. There is a moment that Im landing on a page and I need to check some elements of the page, but its like "loading" continuously so its impossible to find this elements, cause are changing. The only way to find them is in Chrome Settings, Disable JavaScript and perfect it works. But how I disable Javascript with selenium in the same page, without call a new one? Just refreshing or smthg. Thx!!!

ElBandido

You can set that to profiler. Handling would be different based on how you want to do it

var firefoxProfile = new FirefoxProfile();
firefoxProfile.setPreference("javascript.enabled", false);

See this

For Chrome

DesiredCapabilities caps = DesiredCapabilities.chrome();
caps.setCapability("chrome.switches", Arrays.asList("--disable-javascript"));

Taken from here

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