- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to Disable images in Selenium Google ChromeDriver?
We can disable images in Selenium Google chromedriver. The images are disabled so that page load is quicker and execution time is also less. In chromedriver, we have to configure the below browser parameter −
profile.managed_default_content_settings.images, and set its value to 2.
Syntax
p.put("profile.managed_default_content_settings.images", 2);
Let’s try to disable images from the below page −
Example
Code Implementation.
import org.openqa.selenium.By; import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.chrome.ChromeOptions; import java.util.HashMap; import java.util.Map; public class ImageDisable { public static void main(String[] args) throws IOException { System.setProperty("webdriver.chrome.driver", "C:\Users\ghs6kor\Desktop\Java\chromedriver.exe"); Map<String, Object> p = new HashMap<String, Object>(); // browser setting to disable image p.put("profile.managed_default_content_settings.images", 2); //capabilities added to browser ChromeOptions opt = new ChromeOptions(); opt.setExperimentalOption("prefs", p); // associating desired capabilities to browser WebDriver driver = new ChromeDriver(opt); driver.get("https://www.tutorialspoint.com/about/about_careers.htm"); } }
Output
Advertisements