How can I set up Eclipse/Selenium to run scripts on other browsers on a Mac? - eclipse

Im new to Macs and Im having issues trying to run scripts on any browser, let alone IE or Chrome. Here is what Ive done so far:
Installed the latest versions of Eclipse, Selenium standalone server and Selenium IDE
Installed TestNG framework for Eclipse
Installed Selenium web driver and the JAVA libraries
So far all I can do is just run the test scripts Ive created on FF12.
I have created some test scripts on FF12 using Selenium IDE, then exported them to Eclipse with TestNG and when I try to run them I get this error message "Please add the directory containing ''firefox-bin' or 'firefox'' to your PATH environment"
I have a feeling im missing a lot of steps to properly configure Eclipse & Selenium to run scripts on other browsers (ideally IE9 and the latest version of Chrome). And if thats not bad enough, im using a MacBook Pro (Ive been a PC person all my life). Please be gentle and any advice that I can get would be highly appreciated. Thanks

Short answer
Seems like your firefox executable in not in the system path or in the default location. There are multiple ways to fix this
1.Set the firefox binary path in code
You need to set the webdriver.firefox.bin property. In java you can do this by using the following code:
FirefoxProfile profile = new FirefoxProfile();
WebDriver driver = new FirefoxDriver(new FirefoxBinary(new File("path/to/your/firefox.exe")), profile);
2.Find where your firefox is installed and update that path in your path variable
export PATH=/my/firefox/path/bin:$PATH
3.Specify webdriver.firefox.bin as a system property when you start selenium server.
java -jar seleniumserver.jar -D webdriver.firefox.bin = "/path/to/firefox-bin
Once you do one of the above, your issue should be resolved.
Not so short answer - Why it fails?
Per FirefoxDriver javadoc -
org.openqa.selenium.firefox.FirefoxDriver
An implementation of the {#link WebDriver} interface that drives
Firefox. This works through a firefox extension, which gets installed
automatically if necessary. Important system variables are:
webdriver.firefox.bin - Which firefox binary to use (normally
"firefox" on the PATH).
webdriver.firefox.profile - The name of the
profile to use (normally "WebDriver").
Here, webdriver.firefox.bin determines the path of firefox.exe (in windows) or firefox (in mac).
Usually, when you install firefox in your machine the path to firefox file gets added to the path variable. This will allow the user to call firefox from any place.
Webdriver will look for this firefox executable in the path variable and then in the default location. From selenium code, this default path is defined as given below:
case MAC:
if (!binaryName.endsWith(".app"))
binaryName += ".app";
binaryName += "/Contents/MacOS/firefox-bin";
break;
If your firefox file is not available in /Contents/MacOS/firefox-bin then webdriver will not know where to find it. Hence the failure.

Related

Eclipse Browser has problems with rest api call

I have a problem with my eclipse browser.
If i call the url of my sonarqube server (https://sonar) everthing works fine and eclipse shows me the page. But if i try to call the api (https://sonar/api/system/status) it returns with an error window which says that the page could not be opened. The same url worked for me in normal browsers.
Question
Does eclipse browser has problems with calling rest apis in general? Or is there something i could do to make it work?
System:
Windows 10 Pro (10.0.15063 Build 15063)
Eclipse Oxygen.1a Release (4.7.1a)
Ok, the problem seems to be in IE (which is used by eclipse in default). If i call the url in IE it wants to download the json answer. I changed some values in registry so IE just show me the json in browser directly. After that also eclipse could show me hte result without error.
Here is my ie_json.reg file i executed to change values in registry:
Windows Registry Editor Version 5.00;
; Tell IE 7,8,9,10 to open JSON documents in the browser on Windows XP and later.
; 25336920-03F9-11cf-8FD0-00AA00686F13 is the CLSID for the "Browse in place" .
;
[HKEY_CLASSES_ROOT\MIME\Database\Content Type\application/json]
"CLSID"="{25336920-03F9-11cf-8FD0-00AA00686F13}"
"Encoding"=hex:08,00,00,00
I found this solution at http://developers.de/blogs/holger_vetter/archive/2013/12/13/view-json-in-internet-explorer-7-11.aspx

Cannot disable CompactStrings Java 9 using Netbeans

I am trying to disable the CompactStrings feature of Java 9 using the VM option: -XX:-CompactStrings, but it does not work.
When I tried to debug my application, the COMPACT_STRINGS variable in String class is always true (with or without the VM option)
I have the latest version of Java 9: jdk-9+181
And the Netbeans IDE Build 201709070001
I tried various options to set the VM option and none of them works.
What I tried is:
setting the VM option in app.conf, setting it in project.properties, running netbeans by ./netbeans -XX:-CompactStrings, setting the JVM option in Project->Properties->Run->VM Options
Is this a bug in Netbeans? Or am I doing something wrong?
I tried to reproduce your problem using a trivial "Hello World" Java application. However, toggling the CompactStrings feature in the project properties settings worked fine for me, and caused COMPACT_STRINGS to be set appropriately, so this is not a bug in NetBeans.
Although I am using the same version of Java (181) as you, I have a more recent Dev Build of NetBeans (Build 201709220002), and there are several discrepancies between my project properties screen and yours. For example, mine shows the Runtime Platform field but yours does not:
Something else to check is that you really do have the environment you expect. I find it easy to mess things up when multiple versions of Java and Netbeans are installed.
This is what I see when I do Help -> About:
If your environment looks fine then I can only suggest that you download the latest DEV Build of NetBeans and try again.

I cannot get any browser to open up with selenium using Eclipse (neon) , testNG

I've been using Eclipse to automate my tests for several months. One day I come in to run a test that worked the day before and the Browser (Firefox) is blank. Here is the first part of the error:
org.openqa.selenium.firefox.NotConnectedException: Unable to connect
to host 127.0.0.1 on port 7055 after 45000 ms. Firefox console output:
Default","description":"The default
theme.","creator":"Mozilla","homepageURL":null,"contributors":["Mozilla
Contributors"]},"visible":true,"active":true,"userDisabled":false,"appDisabled":false,"descriptor":"C:\Program
Files (x86)\Mozilla
Firefox\browser\extensions\{972ce4c6-7e08-4474-a285-3208198ce6fd}.xpi","installDate":1499203612256,"updateDate":1499203612256,"applyBackgroundUpdates":1,"skinnable":true,"size":19587,"sourceURI":null,"releaseNotesURI":null,"softDisabled":false,"foreignInstall":false,"hasBinaryComponents":false,"strictCompatibility":true,"locales":[],"targetApplications":[{"id":"{ec8030f7-c20a-464f-9b0e-13a3a9e97384}","minVersion":"52.2.1","maxVersion":"52.2.1"}],"targetPlatforms":[],"seen":true,"dependencies":[],"hasEmbeddedWebExtension":false}
So naturally I throw that into google and look up the error and I see a lot of references to "Geckodriver." Something about if you have FF 47 or later, you need to use this geckodriver. Now my company pushes updates every couple of weeks, so it makes sense that they would upgrade Firefox. My current version is 52, sop I go to Github and download Geckopdriver and point to it like so:
System.setProperty("webdriver.gecko.driver", "*the path to it on my machine*");
Upon trying again I'm still get a blank screen. Following is the error message:
org.openqa.selenium.firefox.NotConnectedException: Unable to connect
to host 127.0.0.1 on port 7055 after 45000 ms. Firefox console output:
Default","description":"The default
theme.","creator":"Mozilla","homepageURL":null,"contributors":["Mozilla
Contributors"]},"visible":true,"active":true,"userDisabled":false,"appDisabled":false,"descriptor":"C:\Program
Files (x86)\Mozilla
Firefox\browser\extensions\{972ce4c6-7e08-4474-a285-3208198ce6fd}.xpi","installDate":1499203612256,"updateDate":1499203612256,"applyBackgroundUpdates":1,"skinnable":true,"size":19587,"sourceURI":null,"releaseNotesURI":null,"softDisabled":false,"foreignInstall":false,"hasBinaryComponents":false,"strictCompatibility":true,"locales":[],"targetApplications":[{"id":"{ec8030f7-c20a-464f-9b0e-13a3a9e97384}","minVersion":"52.2.1","maxVersion":"52.2.1"}],"targetPlatforms":[],"seen":true,"dependencies":[],"hasEmbeddedWebExtension":false}
I'm not able to find any relevant reference that can help with my specific specs (Win 7, FF 52, Eclipse Neon, TestNG)
Since I knew that we create object of chromedriver to test on GoogleChrome, I prefered FireFox. But as I relized problem with FireFox, I thought to try the script on Chrome.
So I changed the browser to this:
System.setProperty("webdriver.chrome.driver", "*path*");
WebDriver driver = new ChromeDriver();
And this time Chrome opened, with only "data;" in the URL. Here was the error message:
org.openqa.selenium.remote.UnreachableBrowserException: Could not
start a new session. Possible causes are invalid address of the remote
server or browser start-up failure. Build info: version: '2.53.0',
revision: '35ae25b', time: '2016-03-15 16:57:40'
I can't seem to get any browser to work, and I have been unproductive, trying to fix this for 3 days. I tried to upgrade the version of selenium, but that required updated jar files, which required me to update my version of chrome to 58, which I cannot due to system policy (updates are disabled by your administrator.) Other solutions were focused on various configurations that I do not have, like Ubuntu and Opera and whatever else.
Can somebody help me to get this working again on ONE browser so I can get back to work? Thank you for any help you can give me!
THANKS!!!
Few things.
Which operating system are you using 32-bit or 64-bit?
make sure the driver (gecko or chrome any other) you have downloaded is as per your operating system.
Try to run them from command line to see what's happening.
if you are using linux, make sure driver has proper permission
1- download latest firefox or chrome driver
2- please update your selenium server dependency, it seems your selenium stand-alone.jar is not compatible with your browser version.
download selenium server latest jar from here
or add below maven dependency in your POM
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-server</artifactId>
<version>3.4.0</version>
</dependency>
please let me know if it solve your issue : )
For Google Chrome, you may try this code:
public class FSO_CheckCase {
WebDriver driver;
#BeforeTest
public void setup ()
{
System.setProperty("webdriver.chrome.driver", "*path*\\chromedriver.exe");
ChromeOptions options = new ChromeOptions();
options.addArguments("test-type");
options.addArguments("start-maximized");
options.addArguments("--js-flags=--expose-gc");
options.addArguments("--enable-precise-memory-info");
options.addArguments("--disable-popup-blocking");
options.addArguments("--disable-default-apps");
options.addArguments("test-type=browser");
options.addArguments("disable-infobars");
driver = new ChromeDriver(options);
driver.manage().deleteAllCookies();
}
#Test(priority = 0)
public void Google () throws InterruptedException
{
driver.navigate().to("http://google.com");
driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
}
If this works, same code can be used for FireFox. Be careful while you mention path where you have saved chromedriver.exe and Geckodriver.exe. Let me know if it still creates problem for you.

Eclipse : Whether to select Local Or Shared File during Remote Debugging

I have made some code changes and deployed the code to Jetty Server which is located Remotely .
Accessed the application through browser and I am trying to debug a Application .
Please tell me whether i need to select the Local File Or Shared File from the Eclipse Debug Configurations .
Please see the screen shot here .
The option shown in your screenshot will not help you automatically get code deployed to your remote Jetty.
The option simply allows you to Share your launch configuration (Remote Java Application - ManageWatchlistCall) in your eclipse workspace. This will allow you to checkin the launch configuration in a versioning control system so your colleagues automatically get the sme Remote Java Application launch configuration.
in order to get new code to your remote server, there are only 2 options :
Redeploy your application on the remote server.
Hotdeploy pieces of code to the remote supported (if the server supports it)
Use Hotswap Bug Fixing (works for small fixes) (*)
(*) If you are running Java Virtual Machine (JVM) V1.4 or higher,
Eclipse supports a feature called Hotswap Bug Fixing (not available in
JVM V1.3 or lower). It allows the changing of source code during a
debugger session, which is better than exiting the application,
changing the code, recompiling, then starting another debugging
session. To use this function, simply change the code in the editor
and resume debugging.

Passing proxy settings to a bundled JRE install4j application?

We provided an application installed with install4j, with bundled JRE, to one of our customers. This customer needs some proxy settings configured manually for this application.
I tried to put deployment.config file in the JRE's lib directory but it didn't seem to change anything. I couldn't find a relevant vmoptions either.
Is there a way to pass these settings to the app/jre?
Is there also a way to instruct the JRE to open the Java console when it runs?
Thanks!
/Shmulik.
You can configure the proxy by setting the VM parameters
proxySet=true
proxyHost=...
proxyPort=...
and for authentication
proxyAuth=true
proxyAuthUser=...
proxyAuthPassword=...
You can set them either in a "Run script" in the startup node of the installer action by calling System.setProperty() for the properties or by passing them on the command line like this:
-DproxySet=true -DproxyHost=... etc
As for your second question (better to ask a separate question on stackoverflow)
Is there also a way to instruct the JRE to open the Java console when it runs?
I assume you mean a terminal window, which can be done by selecting the "Windows console executable" property of the installer. You cannot change this property on the command line because this sets a static flag in the binary format of the Windows executable furing compilation.
I created an installer for WINDOWS as well as for MAC. The
application is using an embedded JRE. While the application runs, it's not
able to detect the proxy settings of the network even the option in
the browser is set to be "Auto Detect". But when the proxy settings provided explicitly in the browser, it's able to detect the proxy settings.
Even the proxy settings are not detected when "LAN Settings->Use automatic configuration script" option is selected and points to the .pac file.
Any suggestion, how to provide the proxy settings with BUNDLED JRE and java program can detect those settings without make any further changes in each machine.