How to enabled SelectorsHub in automated browser window

To open the automated browser window with SelectorsHub follow these steps-

1. Copy the SelectorsHub chrome store url.

https://chrome.google.com/webstore/detail/selectorshub/ndgimibanhlabgdgjcpbbndiehljcpfh/

2. Open a new tab with url http://crxextractor.com/ and click on ‘Start for Free’ then paste the SelectorsHub chrome store url given in step1 into the textfield. Click on download the crx to your local.

3. Now add the below two lines of code into your script before initiating the WebDriver instance in your script:

ChromeOptions options = new ChromeOptions();

options.addExtensions(new File(“path of the crx extension on your local machine”));

driver = new ChromeDriver(options);

5. That’s all. SelectorsHub extension is now enabled in automated browser window. Just put a Thread.sleep at the point where you want your script to pause and inspect the element using SelectorsHub in Selenium browser window.

Sample Code-

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.JavascriptExecutor;
import java.io.File;

public class OpenWindowWithSH {
public static WebDriver driver;
public static void main(String[] args) throws Exception {
System.setProperty("webdriver.chrome.driver", "/Users/sanjaykumar/Documents/chromedriver");

ChromeOptions options = new ChromeOptions();

options.addExtensions(new File("/Users/sanjaykumar/Downloads/extension_3_0_9_0.crx"));

WebDriver driver = new ChromeDriver(options);
driver.get("https://selectorshub.com/");
}
}

Watch the below video tutorial to open browser window with SelectorsHub through Selenium-

Leave a Comment

Your email address will not be published. Required fields are marked *