Can we customize Chrome browser launch with different options using Chrome Java API? [duplicate] - karate

I am using the Karate framework to do the API testing. As part of CI efforts, we send an email at the end of test execution listing the summary of test results. There is a need to include the screeshot of the test execution counts from 'overview-feature.html' file.
I did so through the TestRunner.java file - launched Chrome using Chrome.start() and then using it to take screenshot. It all works well locally on Windows.
However when executing on CI server which is a Unix box, the chrome executable is not present in the default location (usr/bin/google-chrome) and hence the connection for the localhost fails.
Is there a way we can change the default location of the chrome executable?
PS: Apologies if this was too trivial to be asked.

Yes Chrome on CI is hard to get right, refer: https://stackoverflow.com/a/62325328/143475 - note that CI boxes typically are "headless" a browser may not be even installed.
I think the best thing for you is to ZIP the HTML and send it. But I really think you need to work with some CI experts, because the report generation and e-mailing business is normally done by things like Jenkins. What you are doing is certainly not normal or best-practice.
If you really want, there is a Karate Docker container that can give you a proper Chrome instance (see docs) but that is overkill for what you need.
EDIT: The Chrome Java API allows for customization of the executable path and this is in the docs: https://github.com/intuit/karate/tree/master/karate-core#chrome-java-api
It should be something like this:
Chrome.start("/opt/blah/chrome");

Related

Testing frontend webpages solve selenium-ide issues or change to so?

i'm using selenium ide to test webapp frontend webpages.
I'd like to test via cli AND via gui having to mantain one scripts only.
When automating tests via selenium-side-runner it does not handle alert/confirm command if i don't change any "choose ok on next confirmation" with "webdriver choose ok on visible confirmation", but after change it side gui does not handle it.
Even exporting to python has some incokmpatiblity with gui.
Anyone knows the proper way to record a side.script with gui and run with cli without having to modify it and letting run the tests with the gui again?
I've see many complaining about this without solution, do you advise to use another fronted tester in the place of side? Why?
Thanks.
Just reporting what said on github's bug tracker issue 1270 by toddtarsi.
There's no way to have one script only to handle gui and cli tests. We have to wait for selenium-ide v4 (not SELENIUM).
The correct way is webdriver one.

TestCafe headless localization parameters

I am writing a fixture, and multiple tests assert the page's title to be some value. However, I did not account for the fact that the website is localized. My normal browser settings are English, but when I run the testcafe chrome:headless myTests.js my tests fails because the Localization changes, perhaps due to my PC's language?
I have tried running my local chrome installation and adding :userProfile, but without luck sadly.
The only other information I can find regarding this issue is, but I can't make it work:
TestCafe & chrome:headless : how to force the browser language (locale)
I found my answer here - go give them a like if it solves your issue as well.
Solution:
I use the following command to launch chrome headless with a locale specified:
testcafe chrome:headless --lang=en-US

Can't add Bamboo job requirements

I have two agents, one with Myvenv and one without it. To build my application, i need the capability Myvenv. To make sure my application only builds on the agent WITH Myvenv, i wanted to add a requirement to the build job.
Visiting the Configuration of the application -> Requirements -> Add
When i add the following rule: Myvenv exists.
Bamboo won't stop loading.
This is for all Bamboo Requirements i try to add, why doens't it add the requirement? Or is there a other solution to my problem mentioned above?
Added screenshot, with small loading circle
Solution:
Adding a requirement doens't work in Chrome or Firefox, but it does work in IE 11. Thanks to Rich Duncan
First, I would look in the bamboo logs. If you don't find anything conclusive in the logs, I would try switching browsers. I've seen AJAX behavior like this work one way in Chrome and another in Firefox.

is this testing setup correct/possible selenium IDE, ghostdriver, phantom.js, grid and php-webdriver correct?

I would like to run many instances of phantomjs at once. The reason I would like to use phantomjs rather than selenium with firefox/chrome/ie is the cookie separation and the ease of using proxies if every needed (some of our systems will need to be accessed from different IP's). Plus phantomjs seems much slimmer/faster than browsers with "heads".
I would also like to generate the test scripts using selenium IDE (I've experimented with Resurrectio+casperjs its good but selenium seems better) then run them as PHP using php-webdriver.
I've been trying to understand how all these pieces fit together so is would this process work....
Generate the test scripts in selenium IDE with firefox then export them to python
Convert this Python script to a facebooks php-webdriver version. Looks like I'll have to manually do this?
Run Phantom.js with this php script and point it at the selenium java server to execute the script.
Is this all correct? Can I run multiple instances simultaneously on once machine? Will I need grid? Where does ghostdriver fit in all this!?

Implementing selenium with Jenkins and PHPUnit

I'm trying to do set up some Selenium WebTests using PHPUnit, but php is no longer supported by Selenium IDE, does this mean I have to re-write all my tests into php in order to use this method?
I'm trying to set up a continuous integration system, but have never even used one before, I tried using jenkins-php.org but it wasn't very helpful.
The newer releasee Selenium IDE "claims" it does not support PHP,
But you can still convert your IDE to PHP or PHPUnit.
(In Selenium IDE) Option > Options > Enable Experimental Functions.
With this option checked you can switch your format under Options again.
You may still want to review your code.
Hope this helps and it is what you meant by "Selenium IDE does not support PHP".
I was able to find: https://addons.mozilla.org/en-US/firefox/addon/selenium-ide-php-formatters/
It allows output from Selenium to PHP, either PHPUnit format or Selenium Testing.
However after all this playing around it became apparent that the best way was to use htmlSuite, it has the most support when it comes to automation and seems to work out of the box, whereas PHPUnit testing requires lots of tinkering.
After a lot of hacking around it became apparent that the best solution is this tool:
http://www.enjoyxstudy.com/selenium/autoexec/index.en.html
It works out of the box, supports htmlSuite, works with windows and linux, runs most browsers, sends email reports, can get new tests from SVN, integrates with Jenkins well, and works with Selenium tests, its not PHP based tests but it works wonders compared to the other tools I tried out.
Really, so much easier, very user friendly, free and works out the box.