python - Selenium - can I disable javascript only for several urls? -


i need disable javascript several urls, i.e.:

browser.get('http://mydomain.com/page1') # actions js off browser.get('http://mydomain.com/page2') # actions js on browser.get('http://mydomain.com/page3') # actions js on browser.get('http://mydomain.com/page4') # actions js off 

i know can pass firefox profile webdriver.firefox() js off, apply pages. , think creating new webdriver.firefox() instance each page not idea.

what best way solve problem? tia!

split tests 2 big groups. 1 group runs tests js disabled , other group runs js enabled.

that way, pay initial setup cost twice (instead of once per test).

alternatively, organize js in such way goes through global symbol (jquery uses $).

now need 2 implementations of framework. 1 normal implementation , other mock/no-op implementation doesn't when functions of called.

you can use browser.executescript() assign 1 of implementations global symbol.

there couple of downsides, though:

  1. not frameworks play along scheme
  2. you have rewrite lot of existing code make work
  3. if attach scripts dom nodes, might continue work before if keep references internal things.

so suggest try "two groups" approach :-)


Comments

Popular posts from this blog

curl - PHP fsockopen help required -

HTTP/1.0 407 Proxy Authentication Required PHP -

c# - Resource not found error -