Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

extract data using selenium and disable javascript

package DemoAutomation;
 
import java.util.HashMap;
import java.util.Map;
 
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
 
public class JSdisableChrome {
 
           //Disabling JS in Chrome
          @Test()
    public void Chrome_javascript_disable() throws InterruptedException {
        
        System.setProperty("webdriver.chrome.driver", "C:UsersLenovo-I7DesktopSeleniumchromedriver.exe");
        
        ChromeOptions options = new ChromeOptions();
        Map<String, Object> prefs = new HashMap<String, Object>();
        prefs.put("profile.managed_default_content_settings.javascript", 2);
        options.setExperimentalOption("prefs", prefs);
        
        
        WebDriver driver = new ChromeDriver(options);
        
        driver.get("https://www.google.com/imghp");
        driver.findElement(By.name("q")).sendKeys("flowers");
        driver.findElement(By.className("Tg7LZd")).click();
        Thread.sleep(5000);
        
        
        driver.quit();  
        
        
    }
    
    
 
}
Source by www.lambdatest.com #
 
PREVIOUS NEXT
Tagged: #extract #data #selenium #disable #javascript
ADD COMMENT
Topic
Name
7+5 =