ChromeDriver.exe does not exist when running on teamcity - selenium-webdriver

I have created 3 Test Server, IE, Chrome and Firefox.
In TeamCity i created 3 build configuration IE, Chrome and Firefox.
I have 3 Agents AgentIE, AgentChrome and AgentFirefox.
Each agent is assign to specific build configuration example Build Configuration IE is to AgentIE
When i run the Build Configuration Firefox, all tests gets executed but when i run the Build Configuration IE and Chrome tests do not get executed .
Error message indicate that the IE and Chrome exe do not exist but i followed the exe file exist in the directory and in a directory on the PATH environment variable.
MSTest]
Framework.FeatureFiles.AdditionalFieldsFeature.CreateNewAdditionalField_0001 (Create New Additional Field: 0001)
[10:35:53][Framework.FeatureFiles.AdditionalFieldsFeature.CreateNewAdditionalField_0001 (Create New Additional Field: 0001)] Assembly Initialization method Framework.BaseClasses.Base.InitWebdriver threw exception. OpenQA.Selenium.DriverServiceNotFoundException: OpenQA.Selenium.DriverServiceNotFoundException: The chromedriver.exe file does not exist in the current directory or in a directory on the PATH environment variable. The driver can be downloaded at http://chromedriver.storage.googleapis.com/index.html.. Aborting test execution.
[10:35:53][Framework.FeatureFiles.AdditionalFieldsFeature.CreateNewAdditionalField_0001 (Create New Additional Field: 0001)] at OpenQA.Selenium.DriverService.FindDriverServiceExecutable(String executableName, Uri downloadUrl)
at OpenQA.Selenium.Chrome.ChromeDriverService.CreateDefaultService()
at OpenQA.Selenium.Chrome.ChromeDriver..ctor(ChromeOptions options)
at Framework.BaseClasses.Base.GetChromeDriver() in C:\TeamCity\buildAgent\work\eba5cd3c0056fc6a\Framework\BaseClasses\Base.cs:line 61
at Framework.BaseClasses.Base.InitWebdriver(TestContext tc) in C:\TeamCity\buildAgent\work\eba5cd3c0056fc6a\Framework\BaseClasses\Base.cs:line 84
If i run the Chrome build configuration on a agent that is running on the teamcity server, the test gets executed.

I had the exact same issue and I was able to resolve it by doing the following steps:
You need to download the chromedriver.exe for your machine type.
Then put the folder where you save the chromedriver.exe in the Path
variable of the TeamCity server.
Next you need to restart the
TeamCity server.
You can download the latest Chrome Driver here.
Here are some instructions on how to add variable to the path.

Issue was with the path variable on the specific machine.

Related

No selenium server jar found error while running protractor tests in Azure DevOps

I am trying to run protractor test on Azure DevOps pipeline and getting the following error. Notice that jar file path is pointing to my local drive even when the tests are being run from Azure DevOps server. Any idea what I need to do?
Same test works when running from local machine but fails on Azure. I have the selenium-server-standalone-3.141.59.jar in my project's node_modules folder. What I don't understand is that why is it looking at my local machine (C:\Automation) when I am running test from Azure.
[13:33:31] I/launcher - Running 1 instances of WebDriver
[13:33:31] E/local - Error code: 135
[13:33:31] E/local - Error message: No selenium server jar found at
C:\Automation\my_app\node_modules\protractor\node_modules\webdriver
manager\selenium\selenium-server-standalone-3.141.59.jar. Run 'webdriver-manager
update' to download binaries.
This issue may be caused by:
selenium-server-standalone-3.141.59.jar does not exist in your project's node_modules\protractor\node_modules\webdriver-manager\selenium location.
selenium-server-standalone exists with different version.
Try to add a command line task to Update webdriver.
Useful resources:
Error: No selenium server jar found at "Location"
https://medium.com/#ganeshsirsi/protractor-end-to-end-tests-configure-on-ci-cd-tfs-vsts-azure-devops-publish-html-results-9143846f579f
https://learn.microsoft.com/en-us/azure/devops/pipelines/ecosystems/javascript?view=azure-devops&tabs=code#end-to-end-browser-testing

Error in Selenium tests triggered from batch script in TFS Build step

Step 1. I have written selenium tests and bundled it into executable jar.
Step 2. When I execute this jar tests runs normally. Invokes New browser and execute all steps.
Step 3. I created bat file to execute this jar. In this case also test execution happens normally.
Step 4. TFS Build integration. (TFS 2015)
- I created new build definition in TFS
- Added build step "Batch Script"
- Entered path of bat file created in step 3 in build step
- When I Queue this build. bat file gets called and test execution starts. But It does not open new browser..console says Started IE driver...it starts driver internal to build agent. and execution fails on setting value in textbox.
Click to see TFS Build Cosole
I can't use Visual studio tests. Requirement is to selenium tests should be triggered from jar created on Step 1.
Make sure the build agent is running in interactive mode.
First you could try to RDP to the remote build server(the build agent located) and manually run the batch file to see if it works.
If it's also not work then the issue may related the IE browser on the server.
If it works then maybe the TFS build service account don't have enough permission to run the IE driver. Please make sure the build service account has local Admin permission on the build server.

Running AngularJS Protractor with IE11

I am having trouble running AngularJS Protractor through Internet Explorer 11 on Windows 7. It works fine if I use Google Chrome, but with IE11, I get the following error message:
WebDriverError: The path to the driver executable must be set by the webdriver.ie.driver system property: for more information, see https://github.com/SeleniumHQ/selenium/wiki/InternetExplorerDriver.
The latest version can be downloaded from http://selenium-release.storage.googleapis.com/index.html
Within the protractor directory is a sub-directory called selenium, and there is an IEDriverServer file. Furthermore, I have two environment variables set. In my user variables, the variable PATH has a value of C:\Users\user\AppData\Roaming\npm\node_modules\protractor\selenium\
Additionally, in my system variables, the variable "Path" is also set to C:\Users\user\AppData\Roaming\npm\node_modules\protractor\selenium\, but it will still not recognize the IE driver server, even though it DOES recognize the Chrome driver server.
Does anyone have any additional information on what I might be missing or doing wrong? Thank you very much.

Error when execute within a TFS build definition

When I tried to call command-line to get latest update for my TFS mapped folder
TF get /recursive
The call complete successfully from the run window of Windows 7.
However, when I put the call into a .bat file and run it via InvokeProcess within a build definition (guide to do that), it failed.
The message is as below.
Unable to determine the workspace. You may be able to correct this by
running 'tf workspaces /collection:TeamProjectCollectionUrl'
What happens? How can I get around with that?
The reason this is happening is because when you run the command locally, the folder you're downloading is mapped to a workspace. When you execute the command in your build, it's running under the build service account, which doesn't have a workspace mapped for the folder you're specifying.
You shouldn't need to use the tf get command as part of your build. When you configure your build, you can specify which folders should be mapped in the workspace on the "Source Settings" tab. The build process will handle making sure the contents of the folders you map in your workspace are present automatically.
The cause for my issue is that the build agent execute my .bat file under a different Windows account which is something like NTSERVICE; when I run it directly, my TFS login account was used (which was previously remembered in Windows 7 Credential Manager)
So the solution is to put in the login name and password as TF get /login:SomeTFSUsername,SomePassword (see more here)

Launch chrome browser

I am trying to launch chrome browser (version 26.0) using webdriver.
I am getting the following error message.
Exception in thread "main" java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.chrome.driver system property; for more information, see http://code.google.com/p/selenium/wiki/ChromeDriver.
at com.google.common.base.Preconditions.checkState(Preconditions.java:176)
at org.openqa.selenium.remote.service.DriverService.findExecutable(DriverService.java:105)
at org.openqa.selenium.chrome.ChromeDriverService.createDefaultService(ChromeDriverService.java:69)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:107)
at googleSearch.main(googleSearch.java:13)
Code I used:
driver = new ChromeDriver();
driver.navigate().to("http://www.google.com/");
I use mac 10.8.2.
For this to work, you need to:
Install Chrome
Install Chrome Web Driver
Make sure you have the chrome web driver in you path, for example on Windows something pointing to chromedriver2_win32_0.8. You can put that in your path by either: (a) Modifying your windows path environment variable, or; (b) adding the following to your java command line options:
-Dwebdriver.chrome.driver='/path/to/driver'
In case of using selenium grid
-Dwebdriver.chrome.driver='/path/to/driver'
has to be added while creating a node from command line.
1) In case of using selenium without GRID:
System.setProperty("webdriver.chrome.driver","/absolute/path/to/chromedriver");
driver = new ChromeDriver();
does the job.
2) In case of using selenium with GRID:
System.setProperty("webdriver.chrome.driver","/absolute/path/to/chromedriver");
driver = new ChromeDriver();
And from command line, while creating a node for chrome browser one needs to pass
-Dwebdriver.chrome.driver='/absolute/path/to/chromedriver'
The above two changes did the job for me, apart from this I was getting this libnss3.so not found error which I solved by creating a symlink of libnss3.so present in /usr/lib/x86_64-linux-gnu/ folder to /usr/lib/
ln -s /usr/lib/x86_64-linux-gnu/libnss3.so /usr/lib/libnss3.so
PS: Also make sure that you are using 64bit OR 32bit version of chrome driver as per your system.
For chrome to work with selenium-webdriver you need to have not only a working chrome browser installed, but also the chromedriver executable. Note that these are TWO different executable files that both need to be specified.
change the permission of file and then run your code again.
Open command prompt and navigate to directory where your chrome exe exists and write
chmod 777 filename
Hope it will solve your problem.

Resources