Not able to launch IE from selenium Webdriver [duplicate] - selenium

This question already has an answer here:
"OsProcess checkForError : CreateProcess error=193, %1 is not a valid Win32 application" while starting Internet Explorer through Java and Selenium
(1 answer)
Closed 2 years ago.
I am getting this error when I try to launch IE from selenium code.
Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: Unexpected error launching Internet Explorer. IELaunchURL() returned HRESULT 800700C1 ('%1 is not a valid Win32 application.') for URL 'http://localhost:4593/'
code
public class Simple {
public static void main(String[] args) throws IOException {
System.setProperty("webdriver.ie.driver", "./UpdateSyncRate/Library/drivers/IEDriverServer.exe");
WebDriver driver = new InternetExplorerDriver();
driver.manage().deleteAllCookies();
driver.get(URL);
driver.manage().window().maximize();
}
}

%1 not a valid win32 application makes me think there's a problem with your exe. Potential the wrong one or the wrong version?
Have a look at WebDriverManager.
Instead of downloading and mapping drivers manually, it can do it at runtime for you:
WebDriverManager.iedriver().setup();
WebDriver driver = new InternetExplorerDriver();
There's more options you can do. Have a look at their docs.

Related

Selenium web driver to automate Oracle ADF login

This is my first post in stack overflow so please forgive me if I haven't included any important details.
I am currently trying to write a java code using selenium web driver to automate Oracle ADF login and then performing various tests but failing with the following error
Currently I have the following code. Not trying to do anything fancy here but just trying to send the username but it's failing. What am I doing wrong here?
public static void main (final String[] args) throws InterruptedException {
System.out.println("*******************");
System.out.println("Launching FF browser");
System.setProperty("webdriver.gecko.driver", driverPath+"geckodriver.exe");
driver = new FirefoxDriver();
driver.manage().timeouts().pageLoadTimeout(40, TimeUnit.SECONDS);
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
driver.get("http://fusion11.com.au:19000/workspace/index.jsp");
String ActualTitle = driver.getTitle();
System.out.println(ActualTitle);
String ExpectedTitle = "Oracle Enterprise Performance Management System Workspace, Fusion Edition";
Assert.assertEquals(ExpectedTitle, ActualTitle);
Boolean verifyTitle = ActualTitle.equalsIgnoreCase("Oracle Enterprise Performance Management System Workspace, Fusion Edition");
System.out.println(verifyTitle);
WebElement GetUserName= driver.findElement(By.xpath("//*[#id=\"bpm.Logon.1.txtUser\"]"));
GetUserName.sendKeys("username");
System.out.println(GetUserName);
}
Failing with the following error
Selenium - Unable to Locate Element
for the locator //*[#id="bpm.Logon.1.txtUser"]
Remove the \ before bpm and remove the \ after txtuser
example --
Thread.sleep(5000);// this is incase your implicit wait does not work
Blockquote
WebElement GetUserName= driver.findElement(By.xpath("//*[#id="bpm.Logon.1.txtUser"]"));

WebDriver cannot be resolved to a type ChromeDriver cannot be resolved to a type [duplicate]

This question already has answers here:
java.lang.Error: Unresolved compilation problems : WebDriver/ChromeDriver cannot be resolved to a type error while executing selenium tests
(5 answers)
Closed 3 years ago.
I am using all latest versions as in below but still see the issue said in above. Can someone help with it.
Eclipse IDE Version: 2019-12 (4.14.0);
WebDriver (Java) - 3.141.59
ChromeDriver 79.0.3945.36
Here is my code:
package AutomationFrameWork;
import org.openqa.selenium.*;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
org.openqa.selenium.chrome.*;
public class FirstTestCase {
public static void main(String[] args) {
// TODO Auto-generated method stub
WebDriver driver = new ChromeDriver();
System.setProperty("webdriver.chrome.driver", "C:\\Users\\xxxx.000\\Desktop\\Selenium\\chromedriver_win32\\chromedriver.exe");
driver.get("www.google.ca");
System.out.println("Successfully opened the website");
driver.quit();
}
}
Error:
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
WebDriver cannot be resolved to a type
ChromeDriver cannot be resolved to a type
at AutomationFrameWork.FirstTestCase.main(FirstTestCase.java:15)
You need to give like this .Also better to put in a folder than putting on the desktop.
WebDriver driver;
System.setProperty("webdriver.chrome.driver",System.getProperty("user.dir")+"\\Jar_files\\chromedriver.exe");
driver = new ChromeDriver();
System.setProperty() should be prior to driver intialization.
Also check version of chrome browser and chrome driver are in sync.

Firefox browser not invoking from Selenium Webdriver version 3.4.0

So here is the issue:
Basically I'm trying to invoke Firefox browser with selenium.
package basics;
import org.openqa.selenium.WebDriver;
public class BrowserInvocation {
/**
* #param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
System.setProperty("webdriver.gecko.driver","C:\\geckodriver.exe");
WebDriver driver=new FirefoxDriver();
// There is no import option displaying when mouse over FirefoxDriver such as **import org.openqa.selenium.firefox.FirefoxDriver;**
Console output:
Exception in thread "main" java.lang.Error: Unresolved compilation
problem:
FirefoxDriver cannot be resolved to a type at
basics.firefox.main(firefox.java:19)
I'm using latest versions of all software involve (as of May 15 2017) like firefox, java, eclipse and selenium. I have use 32 bit versions and 64 bit versions. tried removing everything and setup environment again but no luck.
I have tried invoking chrome in same environment with chrome driver and so far at least I can invoke the browser.

Webdriver exception selenium grid

Not able to launch test after setting all , here is code :
public void browserSetup() throws MalformedURLException
{
DesiredCapabilities capability =DesiredCapabilities.firefox();
driver=new RemoteWebDriver(new URL(nodeurl),capability);
capability.setBrowserName("firefox");
capability.setPlatform(Platform.VISTA);
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.get(PageUrlReff.HomePageUrl);
}
Getting following error:
org.openqa.selenium.WebDriverException: The path to the driver executable must be set by the webdriver.gecko.driver system property
On the machine that is running your Selenium node please download the binaries for
ChromeDriver
GeckoDriver
IEDriverServer (Assuming your node is a WINDOWS box, if not, then you don't need this)
and make the location of these binaries available as part of your PATH environment variable. After that your automation should run fine and you wouldn't be seeing this error message.

How to use Phantomjs for opening a website in Selenium

I'm trying to use headless webkit of PhantomJs for opening google.com through selenium webdriver but when I execute the code system throws an error. phantomJs.exe is placed in E directory. Please help me resolve this issue.
public static void main(String[] args) throws Exception {
DesiredCapabilities caps = new DesiredCapabilities();
caps.setJavascriptEnabled(true);
caps.setCapability(PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY, "E:\\phantomjs.exe");
WebDriver driver = new PhantomJSDriver();
driver.get("http://www.google.com");
}
Error:
Exception in thread "main" java.lang.IllegalStateException: The path to the driver executable must be set by the phantomjs.binary.path capability/system property/PATH variable; for more information, see https://github.com/ariya/phantomjs/wiki. The latest version can be downloaded from http://phantomjs.org/download.html
at com.google.common.base.Preconditions.checkState(Preconditions.java:197)
at org.openqa.selenium.phantomjs.PhantomJSDriverService.findPhantomJS(PhantomJSDriverService.java:236)
at org.openqa.selenium.phantomjs.PhantomJSDriverService.createDefaultService(PhantomJSDriverService.java:181)
at org.openqa.selenium.phantomjs.PhantomJSDriver.(PhantomJSDriver.java:104)
at org.openqa.selenium.phantomjs.PhantomJSDriver.(PhantomJSDriver.java:94)
at multidrivers.main(multidrivers.java:35)
Exception in thread "main" java.lang.IllegalStateException: The path to the driver executable must be set by the phantomjs.binary.path capability/system property/PATH variable;
The above issue is due to the driver not being initialized with the DesiredCapabilities object:
WebDriver driver = new PhantomJSDriver();
Updating the code as below should solve your issue:
WebDriver driver = new PhantomJSDriver(caps);
Let me know if you have any queries.