Skip to content
This repository was archived by the owner on Nov 29, 2018. It is now read-only.

How to disable JavaScript in chrome using Chrome driver #3175

Closed
lukeis opened this issue Mar 3, 2016 · 5 comments
Closed

How to disable JavaScript in chrome using Chrome driver #3175

lukeis opened this issue Mar 3, 2016 · 5 comments

Comments

@lukeis
Copy link
Member

lukeis commented Mar 3, 2016

Originally reported on Google Code with ID 3175

Hi,

In my project we need to do automation for javascript disable of chrome browser.

I have tried below code using chrome driver but no luck.

DesiredCapabilities capabilities = DesiredCapabilities.Chrome();
                capabilities.IsJavaScriptEnabled = false;
                capabilities.Platform = plat;
                OpenQA.Selenium.Chrome.ChromeDriver driver = new OpenQA.Selenium.Chrome.ChromeDriver(capabilities);

  driver.Navigate().GoToUrl("http://tk3ftptlwbvm16/onemscom/default.aspx");

could you please let me know is there any other way to disable the javascript and perform
required clicks / actions

Thanks in advance.

Regards,
Praveena.


Reported by praveena14785 on 2012-01-10 08:13:46

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

This is not the proper forum for general help requests. In the future, please direct
your WebDriver questions to the webdriver@googlegroups.com mailing list.

As for your bug, you can disable JavaScript using Chrome's --disable-javascript flag.
 In Java:

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

*WARNING*: Running without JavaScript is unsupported and will likely break a large
portion of the ChromeDriver's functionality. I suspect you will be able to do little
more than navigate to a page.  This is *NOT* a supported use case, and we will not
be supporting it.

Reported by jmleyba on 2012-01-10 16:52:38

  • Status changed: WontFix
  • Labels added: Component-WebDriver, Browser-Chrome

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

this and that not work expectly!

Reported by stu.pro.2014 on 2013-11-19 05:15:08

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

this still don't work. both attempts

Reported by Eeezyy on 2014-07-10 12:13:05

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016


class Test(unittest.TestCase):
    def setUp(self):
        self.driver = webdriver.Chrome()
        self.driver.implicitly_wait(30)
        self.base_url = "chrome://settings-frame/content"
        self.verificationErrors = []
        self.accept_next_alert = True

    def test_(self):
        driver = self.driver
        driver.get(self.base_url)
        source = driver.page_source;
        #drive.switch_to_frame('chrome');
        #print(source);
        driver.find_element_by_xpath("//input[@type='radio' and @name='javascript'
and @value='block']").click();
        time.sleep(5);
        self.driver.find_element_by_id('content-settings-overlay-confirm').click();

        driver.get('https://www.whatismybrowser.com/');
        time.sleep(5);
    def tearDown(self):
        self.driver.quit()
        self.assertEqual([], self.verificationErrors)

if __name__ == "__main__":
    unittest.main()

Reported by ashish.rawat417 on 2015-04-20 22:43:24

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

Reported by luke.semerau on 2015-09-17 18:14:31

  • Labels added: Restrict-AddIssueComment-Commit

@lukeis lukeis closed this as completed Mar 3, 2016
@SeleniumHQ SeleniumHQ locked and limited conversation to collaborators Mar 4, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant