Selenium.WebDriver - I get error when I try to run my test in Chrome - selenium

I get this error when I try to run my test in Chrome:
Initialization method AutomationUsingSelenium.SmuladorChrome.MyTestInitialize threw exception. OpenQA.Selenium.DriverServiceNotFoundException: OpenQA.Selenium.DriverServiceNotFoundException
What is the cause?

Finally I resolved my issue as follows:
1) I copied chromedriver.exe in Chrome directory link, but you can put it in any directory. I decided to put it here.
2) I Initialized a new instance of the ChromeDriver class using the specified
// path to the directory containing ChromeDriver.exe
My code:
IWebDriver drive = new ChromeDriver
("C:\\Documents and Settings\\...\\ApplicationData\\Google\\Chrome\\Application");
And it works just perfect. Thanks All.

Install Selenium.Chrome.WebDriver NuGet package to the project and you will not get the error again.
In Visual Studio, right click the Project, click Manage NuGet Packages... , Search for Selenium.Chrome.WebDriver and click install.
Enjoy Selenium.

Lets assume chromedriver.exe is present in below path: G:\Selenium_Csharp\Jar\chromedriver_win32\chromedriver.exe
To execute your test in Chrome set the path to the directory/folder containing chromedriver.exe without selecting chromedriver.exe file name.
driver = new ChromeDriver("G:\\Selenium_Csharp\\Jar\\chromedriver_win32");
driver.Url ="http://www.gmail.com";
driver.Manage().Window.Maximize();
OR
driver = new ChromeDriver(#"G:\Selenium_Csharp\\Jar\\chromedriver_win32");
driver.Url ="http://www.gmail.com";
driver.Manage().Window.Maximize();

This is the error i see:
OpenQA.Selenium.DriverServiceNotFoundException: The chromedriver.exe file does not exist in the current directory or in a directory on the PATH environment variable.
I resolved this problem by specifying the 'testsettings' argument in the command to run the unit tests.
E.g.
E:\Development\SampleProject\SampleProject.MvcWebApp\SampleProject.MvcWebApp.JavaScriptUnitTests\JavaScriptUnitTests\bin\Debug>"C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\mstest.exe" /testcontainer:JavaScriptUnitTests.dll /category:"JavaScriptUnitTests" /testsettings:..\..\..\Local.Testsettings /resultsfile:..\..\..\..\..\MsTestResults\SampleProject.MvcWebApp.JavaScript.Tests.trx
I use "/testsettings:......\Local.Testsettings" because the Local.testsettings file is 4 levels higher than the level where I am executing this command. You should change it accordingly.
This is the command used in ccnet.config file
<exec>
<executable>C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\mstest.exe</executable>
<baseDirectory>SampleProject.MvcWebApp\SampleProject.MvcWebApp.JavaScriptUnitTests\JavaScriptUnitTests\bin\Debug</baseDirectory>
<buildArgs>/testcontainer:JavaScriptUnitTests.dll /category:"JavaScriptUnitTests" /testsettings:..\..\..\Local.Testsettings /resultsfile:..\..\..\..\..\MsTestResults\SampleProject.MvcWebApp.JavaScript.Tests.trx</buildArgs>
<successExitCodes>0</successExitCodes>
</exec>

Related

IntelliJ IDEA error: cannot find vm options file

I'm trying to launch IntelliJ IDEA but the following error pops up:
Cannot find vm options file
This happened to me in Ubuntu 16.4, and the pycharm.vmoptions file was under the bin/ directory.
I was trying to run the shell script with this commands:
cd <path_to_pycharm_installation>/bin
source pycharm.sh
Running the bash script without the "source" command solved it for me:
./pycharm.sh
The explicit solution is to set an environment variable named $IDEA_VM_OPTION:
export IDEA_VM_OPTION="[path-to-'.vmoptions' file]"
Search in the file idea.sh:
grep -ri "vmoption" ./bin/idea.sh
You will see that the search path for .vmoptions file is either:
$HOME/.IntelliJIdea2016.2/idea$BITS.vmoptions
or
$IDE_BIN_HOME/idea$BITS.vmoptions
So, copy file bin/idea64.vmoptions into one of above locations if you have 64 bit JVM installed or file bin/idea.vmoptions else.
The following information is current as of April 23, 2019 for version 2019.1.1 of IntelliJ Ultimate that was installed via JetBrains Toolbox app version 1.14.5179
Locate the start menu item for IntelliJ. For me, it was at:
%APPDATA%\Microsoft\Windows\Start Menu\Programs\JetBrains Toolbox\
with the name:
IntelliJ IDEA Ultimate
right-click on the above item and choose Properties
Change the empty Start In: text box to read:
%LOCALAPPDATA%\JetBrains\Toolbox\apps\IDEA-U\ch-0\191.6707.61\bin\
Once the above work-around has been performed, IntelliJ 2019.1.1 Ultimate will stop emitting the error:
Error launching IDEA cannot find VM options file

Jenkins: Error in Selenium Publish Report

I have properly configured the Seleniumhq plugin into Jenkins. I've also tried to run it in my local Jenkins and it worked. The problems I encounter are as follows:
suiteFile directory reads from C drive ONLY. Example, C:\TestSelenium\testSuite.html
When I try to specify the absolute path to my test suite (workspace), I get the error
The suiteFile is not a file or an url ! Check your build configuration.
Same thing happens with resultFile.
When I add post-build action "Publish Selenium Report," I'm getting an error because the newly created resultFile is saved into C:\TestResult\result.html and not in the workspace.

I am trying to open Jmeter by the batch file but it gives me a Windows error

Here is the related error its showing:
java.exe is not a recognized file as an internal or external command,
operable or external command
errorlevel=9009
i was getting the same error on WIndows 8.1(64 bit) and checked java path but it was ok
so i just run my jmeter.bat with Run as Administrator and it worked for me
Many operating systems have an environment variable such as PATH that contains a list of directories (or folders) to be searched when looking for a command to execute. Commands that can be found via the PATH are commonly called external commands. The program that reads the command line or the batch file and invoked the commands may have a number of built in commands, these are commonly called internal commands.
I suggest you examine the PATH (or equivalent) set when your java command executes from the command line and also when execution is attempted from the batch file. Compare the two and make sure the directory containing your java.exe is in the PATH.
Does not work with Java 9 beta:
Running:
C:\java -version
Gives:
java version "9-ea"
Just go into command line and run:
java -jar ApacheJMeter.jar
Set the correct Java Path (installed in your system) in Computer -> Advanced System settings -> Environment Variables -> Ok -> System Variables -> Path
I got the same issue and resolved by following the above steps.
I tried everything, this eventually worked.
Within System Variables:
PATH = "C:\WINDOWS\system32;C:\WINDOWS;C:\Program Files\Java\jdk1.8.0_101\bin"
May help someone.
This error occurs due to the path has not been set properly.
Either you can set it in environmental varialables or right click jmeter .bat file,choose edit set the path their,for reference see the jmeter.apache.org user manuals.
For me, my Java path has a space in it and jmeter said it can't find Java
/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home
.. I looked at the jmeter.sh script and saw it got the path from "Plugin-Ins" .. onward. I tried just commenting out the exit command after that check in the script .. and then I was able to run jmeter.
So apparently the validation logic has a bug, where the error message about can't find java is in fact not true (if Java is indeed set up correctly), so it can be ignored.
For windows 8.1 Users:
Error when trying to run jmeter.bat
Error message:
Not able to find Java executable or version. Please check your Java installation. errorlevel=2
Press any Key to continue
Resolution:
Right Click jmeter.bat and Run as Administrator.
This worked for me, hope this helps. Good luck
Set the correct JM_LAUNCH variable to java.exe
For Windows XP users set Java environment by following the steps here:
http://www.tutorialspoint.com/jmeter/jmeter_environment.htm
Note the path depends on your installed JDK.
And download the file from:
https://svn.apache.org/repos/asf/jmeter/trunk/bin/jmeter.bat
Then replace your jmeter.bat with the downloaded file.
If you have installed Java and still you get this error, please set the java_home path to below using typing below command in terminal:
export JAVA_HOME="/Library/InternetPlugIns/JavaAppletPlugin.plugin/Contents/Home"
Since I run many versions of Java.. I modified jmeter.bat.
rem JM_START - set this to "start" to launch JMeter in a separate window
rem this is used by the jmeterw.cmd script.
rem
rem =====================================================
setlocal
rem Minimal version to run JMeter
set MINIMAL_VERSION=1.8.0
set PATH=%PATH%;C:\Program Files (x86)\IBM\Java80\jre\bin <<< add This line to jmeter.bat
Copied the JAVA executable from Installed version of Java from C:\Program FilesJava\jdk1.8.0_191\bin and pasted in the folder where the jmeter bat resides and it worked for me.
Not exactly the same issue but somebody might find it helpful
Do not double click jmeter.bat but instead ApacheJMeter.jar in the same directory
For me jmeter.bat run but for a brief moment closing almost immediately and not prompting any error. Above workaround allowed me to start working
if JAVA -version shows as blank or empty in the command prompt (CMD) then you need to clear the all java paths in environment variable and again add JAVA_HOME=C:\Program Files\Java\jdk-11.0.15.1
path= C:\Program Files\Java\jdk-11.0.15.1\bin;
if you see C:\Program Files\Common Files\Oracle\Java\javapath; like this remove this
and try in new CMD prompt then Java -version will work.

Running selenium tests from Jenkins - cannot find firefox

I have some selenium tests written in java and built using maven. The pom file includes the jbehave and selenium libraries. It uses firefox browser. So I installed firefox on linux and included the path in my .bashrc. If I do a mvn clean install manually , it works fine.
But if I try the same thing using Jenkins ( am trying to automate the tests), it is throwing errors:
[ERROR] FATAL ERROR
[INFO] ------------------------------------------------------------------------
[INFO] null
Cannot find firefox binary in PATH. Make sure firefox is installed. OS appears to be: LINUX
Caused by: org.openqa.selenium.WebDriverException: Cannot find firefox binary in PATH. Make sure firefox is installed. OS appears to be: LINUX
I tried doing an echo of PATH within Jenkins and it did not show the path of firefox. So I also did an export PATH with the new path of firefox included and then called mvn clean install in Jenkins. Even though the PATH now showed the path of firefox in jenkins console output, it still throws the same error.
What is that I am missing?
Three things to check:
1) as #shawnzhu said, check whether you have installed firefox properly?
2) To provide Binary path to your driver, you need to set system property. Use below code for selenium with java:
File firefoxPathBinary = new File("path/to/your//firefox-bin");
System.setProperty("webdriver.firefox.bin", firefoxPathBinary.getAbsolutePath());
driver = new FirefoxDriver();
3) For Ubuntu, path to your firefox executable could be - usr/lib/firefox/firefox-bin and for Mac it could be /Applications/Firefox.app/Contents/MacOS/firefox-bin
You probably need to link the executable:
sudo unlink /usr/bin/firefoxsudo ln -s /path/to/new/firefox/executable /usr/bin/firefox

Path not found by DPInst

I'm installing a driver using WiX with DPInst, as per this tutorial. It works fine on Windows 7, but I'm trying it on Windows XP, and I get an error dialog popping up saying:
ERROR: Path 'C:\Program Files\My Driver\package\driver.inf' not found
after which it prints a long usage message.
If I navigate to C:\Program Files\My Driver\package\driver.inf before I close the dialog, the file is there, at that location. In the InstallExecuteSequence, InstallDriver is set to happen Before InstallServices. What's going wrong?
Note: I've tried running DPInst from the command line, and I get the same error.
Also, I've tried moving DPInst into the same directory as the .inf and tried running it without the /PATH argument. Strangely, I still get the same error (that is, it gives the exact path to the .inf that it "can't find". This is very strange indeed.
I think that when you want to install a driver using DPInst.exe with /path you should only provide the path to the directory that contains the .inf file. That is: dpinst.exe /path "C:\Program Files\My Driver\package\".