How to disable local storage feature in Selenium? - selenium

I want to test the code that must run when the browser does not have / does not allow me to use the local storage feature. Is there any way to mock this behavior on Selenium side?

Take a look at this question and the answers:
How can I browse with localstorage disabled?
It's not specifically about selenium, but it tells you how to configure the browsers to disable local storage; using that, you should be able to run selenium with a browser using that configuration.

Related

How we can automate real browser instead of using selenium browser instance

I am trying to scrape a website, but it is not loading in selenium. When I browse that website in my "real" chrome browser, everything works fine. Is there any way I can use my real browser with python to automate stuff, instead of using selenium??
Thanks
Using selenium we can automate real browsers.
If in case the website is not loading via selenium, you can check if adding desired capabilities helps.
Here we can set proxy, disable extensions etc. There are many options available.
https://chromedriver.chromium.org/capabilities
Also if you can share what kind of error is displayed that would be helpful.

How to run TestCafe tests with throttling connection?

I need to check functionality if a file is uploading longer then 1 minute.
To check it with manual testing I use Chrome Dev Tools to set Throttling "Slow 3G".
But I can't figure out how to do it with TestCafe.
TestCafe does not have an API to set the throttling. However, TestCafe uses Chrome DevTools Protocol internally so you can get access to internal CDP methods.
Please refer to the following links to get started:
Chrome DevTools Protocol
chrome-remote-interface package
chrome-remote-interface repo
Please also take a look at the following example which shows how to enable file downloading in chrome headless.
I think you need to combine this example with the CDP Network.emulateNetworkConditions method.
Please refer to this article https://chromedevtools.github.io/devtools-protocol/tot/Network#method-emulateNetworkConditions

Support for IE recording

SmartMeter saves huge time using the built in test recorder but it has a limitation where user has to use built in chromium browser.
May I know How to record business transaction using alternate browser (IE, Firefox) ?
Unfortunately, you cannot use Chromium plugin with a different browser. It is dependent on Chrome API. But you can always fallback to JMeter way. The HTTP(S) Test script recorder is still available in SmartMeter. There is also Smart Proxy Recorder, which extends the capabilities of HTTP(S) Test script recorder, but it still based on recording via proxy.

Is there any API to disable prerender feature in chrome?

Without using automation, is there any way to programmatically disable prerender feature (Advanced Setting: Predict network actions to improve page load performance) in google chrome?
I couldn't find any straight forward API that allows me to modify this setting. So, I tried modifying dns_prefetchin->enabled in the "[Chromedir]\User Data\Default\Preferences" file to "false". But that value was getting reset every time I open Chrome. Using the Procmon utility didn't provide me any additional clues on where chrome may store its settings.
Thanks in advance.
Edit: I should mention upfront that using command line option --prerender won't work as I need this value to be turned off for all instances of chrome (even when launched by Operating system shell).

Restricting Selenium/Webdriver/HtmlUnit to a certain domain

While using selenium/webdriver for web scraping, I realized the target site has google analytics script running. Is there a way to restrict selenium/webdriver/htmlunit to avoid certain urls/domains ?
Thanks,
I think it is impossible becouse Selenium is actually adapter for several implementation. So he can't deny to load some scripts to firefox or chrome. Perhaps you can check driver api(firefox profile, htmlunit configuration file) to accomplish this.