I am using Selenium 2 with python bindings to fetch some data from our partner's site. But on an average it's taking me around 13 secs to perform this operation.
I was looking for a way to disable the images css and flash etc.
I am using Firefox 3.6 and also using pyvirtualdisplay to to prevent opening of firefox window. Any other optimization to speed up firefox will be also helpful.
I have already tried network.http.*
options but does not help much.
And also set the permissions.default.image = 2
Generally to run tests on our local machine, we will just specify as WebDriver driver = new FirefoxDriver(); to run on Firefox browser. System. setProperty("webdriver. gecko.
We can download images with Selenium webdriver in Python. First of all, we shall identify the image that we want to download with the help of the locators like id, class, xpath, and so on. We shall use the open method for opening the file in write and binary mode (is represented by wb).
I have figured out a way to prevent Firefox from loading CSS, images and Flash.
from selenium.webdriver.firefox.firefox_profile import FirefoxProfile def disableImages(self): ## get the Firefox profile object firefoxProfile = FirefoxProfile() ## Disable CSS firefoxProfile.set_preference('permissions.default.stylesheet', 2) ## Disable images firefoxProfile.set_preference('permissions.default.image', 2) ## Disable Flash firefoxProfile.set_preference('dom.ipc.plugins.enabled.libflashplayer.so', 'false') ## Set the modified profile while creating the browser object self.browserHandle = webdriver.Firefox(firefoxProfile)
Thanks again @Simon and @ernie for your suggestions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With