How to launch the Chrome Postman Plugin using Selenium Webdriver - java

ChromeDriver driver = new ChromeDriver();
ChromeOptions options=new ChromeOptions();
options.addArguments("chrome-extension://fdmmgilgnpjigdojojpjoooidkmcomcm/index.html");
driver = new ChromeDriver(options);
Tried using the above code.

You can open extension page using below code :
public class sample {
public static void main(String[] args) {
System.setProperty("webdriver.chrome.driver", "yourpath/chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.get("chrome://extensions/");
}
}
If you want to open plugin page then user below code :
public class sample {
public static void main(String[] args) {
System.setProperty("webdriver.chrome.driver", "yourpath/chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.get("https://chrome.google.com/webstore/search/postman?hl=en-US");
}
}
Note : if you have not downloaded "chromedriver" yet , then please download from HERE

Related

URL is not opening in chrome in selenium

This is my code and requirement is that, need to open URL in same local chrome path. Is it possible??
public class Test{
public static void main(String args[]){
System.setProperty("webdriver.chrome.driver","C://Program Files (x86)//Google//Chrome//Application//chrome.exe");
WebDriver d= new ChromeDriver(); ;
String baseurl = "http://www.facebook.com/";
d.get(baseurl);
}
}
System.setProperty("webdriver.chrome.driver", "C:\\Users\\User\\Downloads\\chromedriver83\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
String baseurl = "http://www.facebook.com/";
driver.get(baseurl);
Check the path of chromedriver.exe carefully from your machine.
For Windows users:
System.setProperty("webdriver.chrome.driver","C:\\Users\\user\\Downloads\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.get("http://www.facebook.com");
For MAC users:
System.setProperty("webdriver.chrome.driver","//Users//apple//Downloads//chromedriver");
WebDriver driver = new ChromeDriver();
driver.get("http://www.facebook.com");

org.openqa.selenium.WebDriverException: java.net.ConnectException , HOW CAN i RESOLVE

public class Prog1 {
public static void main(String[] args) {
System.setProperty("WebDriver.chrome.driver", "D:\\Users\\sh\\workspace\\Java2020\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver1.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
System.out.println("Hello world");
You need to replace this line; don't use upper case "Webdriver.chrome.driver"
System.setProperty("webdriver.chrome.driver", "C:/drivders/chromedriver.exe");
And also change this driver1 to use driver
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
Time out exception driver object should be driver instead of driver1

Java- Why Selenium Chrome webdiver is using my real IP adress instead of the proxy

I'm trying to browse with Selenium using a proxy but it fails and show my public IP instead
public static void main(String[] args) {
System.setProperty("webdriver.chrome.driver", "D:\\driverChrome.exe");
ChromeOptions option = new ChromeOptions();
Proxy proxy = new Proxy();
proxy.setHttpProxy("200.111.182.6:443");
option.setCapability(CapabilityType.PROXY, proxy);
WebDriver driver = new ChromeDriver(option);
driver.get("https://whatismyipaddress.com");
driver.manage().window().maximize();
}
As per the Java Docs setCapability() method from MutableCapabilities is defined as:
setCapability
public void setCapability(java.lang.String key, java.lang.Object value)
So instead of setCapability(CapabilityType.PROXY, proxy) you have to use setCapability("proxy", proxy);. So effectively your code block will be:
public static void main(String[] args) {
System.setProperty("webdriver.chrome.driver", "D:\\driverChrome.exe");
ChromeOptions option = new ChromeOptions();
Proxy proxy = new Proxy();
proxy.setHttpProxy("200.111.182.6:443");
option.setCapability("proxy", proxy);
WebDriver driver = new ChromeDriver(option);
driver.get("https://whatismyipaddress.com");
driver.manage().window().maximize();
}
tl; dr
Capabilities & ChromeOptions
The following code solved my problem
public static void main(String[] args) {
System.setProperty("webdriver.chrome.driver", "D:\\driverChrome.exe");
ChromeOptions option = new ChromeOptions();
option.addArguments("--proxy-server=http://51.38.22.57:8522");
WebDriver driver = new ChromeDriver(option);
driver.get("https://whatismyipaddress.com");
driver.manage().window().maximize();
}

Firefox browser is not opening in Selenium webdriver in eclipse

I'm using Firefox 45.8.0 version and I tried below code to open Firefox browser but i'm getting error that: "The path to the driver executable must be set by the webdriver.gecko.driver system property".
Please sagest me how to set the path.
Note:gecko driver will work for above firefox version 48.
package First;
import org.openqa.selenium.firefox.FirefoxDriver;
public class City {
public static void main(String[] args) {
// TODO Auto-generated method stub
FirefoxDriver c1=new FirefoxDriver();
c1.get("http://google.com");
}
}
Try this below code.
In your code you were not provide gecko driver path. You can download gecko driver from this link
public class City {
public static void main(String[] args) {
System.setProperty("webdriver.gecko.driver", "C:\\Drivers\\geckodriver.exe");
WebDriver driver = new FirefoxDriver();
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(25, TimeUnit.SECONDS);
driver.get("http://google.com");
}
}

Not able to run selenium script using phantomjs driver

I am new to phantomjs driver, I need to run my script in background using phantomjs headless driver.
Here is my code i am getting null-pointer exception.
currently am using selenium 2.32,testNG,phantomjs jar 1.0.3
public class PhantomjsDemo {
public WebDriver driver;
#BeforeMethod
public void setup(){
DesiredCapabilities caps = new DesiredCapabilities();
caps.setJavascriptEnabled(true);
caps.setCapability("takesScreenshot", true);
caps.setCapability(PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY,"C:\\phantomjs-1.9.2-windows\\phantomjs.exe");
WebDriver driver = new PhantomJSDriver(caps);
driver.get("www.google.com");
}
#Test
public void google(){
driver.findElement(By.xpath("//*[#id='gbqfba']")).getText();
driver.findElement(By.xpath("//*[#id='gbqfba']")).getSize().getHeight();
driver.findElement(By.xpath("//*[#id='gbqfba']")).getSize().getWidth();
driver.findElement(By.xpath("//*[#id='gbqfba']")).click();
}
#AfterMethod
public void close(){
driver.quit();
}
}
You are not initializing your Webdriver member variable in the setup() method, but a method variable:
WebDriver driver = new PhantomJSDriver(caps);
Change it to
this.driver = new PhantomJSDriver(caps);
and the NPE should go away.

Categories

Resources