I am running the following script based on the RSelenium Basics CRAN page:
library(RSelenium)
startServer(args = c("-port 4455"), log = FALSE, invisible = FALSE)
remDr <- remoteDriver(browserName = "chrome")
remDr$open()
This produces the following error:
Exception in thread "main" java.net.BindException: Selenium is already running on port 4444. Or some other service is.
at org.openqa.selenium.server.SeleniumServer.start(SeleniumServer.java:492)
at org.openqa.selenium.server.SeleniumServer.boot(SeleniumServer.java:305)
at org.openqa.selenium.server.SeleniumServer.main(SeleniumServer.java:245)
at org.openqa.grid.selenium.GridLauncher.main(GridLauncher.java:64)
Based on the comments from this conversation on GitHub, I've modified my startServer() command like so:
startServer(args = c("-port 4455"), log = FALSE, invisible = FALSE)
I then receive the following error in my console:
Error: Summary: UnknownError
Detail: An unknown server-side error occurred while processing the command.
class: java.lang.IllegalStateException
And this error in the Java prompt that pops up:
14:38:55.098 INFO - Launching a standalone Selenium Server
14:38:55:161 INFO - Java: Oracle Corporation 25.40-b25
14:38:55.161 INFO - OS: Windows 7 6.1 amd64
14:38:55.161 INFO - v2.46.0, with Core v2.46.0. Built from revision 87c69e2
14:38:55.209 INFO - Driver class not found: com.opera.core.systems.OperaDriver
14:38:55.209 INFO - Driver provider com.opera.core.systems.OperaDriver is not registered
14:38:55:289 INFO - RemoteWebDriver instances should connect to: http://127.0.0.1:4455/wd/hub
14:38:55:289 INFO - Selenium Server is up and running
I'm not sure if the lack of an Opera driver is an actual error or just a warning. Regardless, I would like to use Chrome, so it seems like it shouldn't matter. What am I doing wrong?
I was finally able to get RSelenium to work by piecing together information from a number of different sources. I think it would be helpful to have all of this information in one location, so here is the process that I went through to get RSelenium to work on Windows 7 (64-bit) with Chrome as the browser:
Download the 64-bit version of Java. I could not get anything to work with the standard download.
Download ChromeDriver.
Download the Selenium Standalone Server or run checkForServer() from R.
Create a batch file to start the Selenium server. I initially tried to use startServer() from an R script, but it would frequently get stuck and not carry on to the next line in the script. Here is the batch file that I created:
java -jar C:\path\to\selenium-server-standalone.jar -Dwebdriver.chrome.driver=C:\path\to\chromedriver.exe
ChromeDriver can be put in the PATH environmental variable, but I decided to add in the path to ChromeDriver to the batch file (which accomplishes the same goal).
Run the R script. Here is my final script:
library(RSelenium)
shell.exec(paste0("C:\\path\\to\\yourbatchfile.bat"))
Sys.sleep(5)
remDr <- remoteDriver(browserName = "chrome")
remDr$open(silent = TRUE)
remDr$navigate("http://www.google.com")
The Sys.sleep() call was necessary because I would get an error in the remoteDriver() call if it ran before the Selenium Server had finished starting.
It is worth noting that RSelenium has some annoying differences for OSX. The invisible=T/silent=T arguments will not work when you run the yourcommand.command file and the remDr$open() method, respectively. The invisible=T will actually remind you that it only works on Windows. Not a huge deal (and if someone has a workaround I'd appreciate it).
For posterity's sake here's a slight variation for OSX to replace shell.exec using a .command file instead of a .bat with the same contents as above:
yourcommand.command file contents
java -jar /path/to/selenium-server-standalone.jar -Dwebdriver.chrome.driver=/path/to/chromedriver
R script modification
library(RSelenium)
system(paste("open","/path/to/yourcommand.command"))
Sys.sleep(5)
...
Related
Attempting to run Appium automation scripts on iOS (simulator) on a Mac Mini (M1 chip, if that's relevant). When I run the tests, they work just fine when the Appium server is started manually (typing "appium" into the terminal and starting it that way). However, when I attempt to start the appium server programmatically, the application under test fails to launch, with the following error:
2021-02-17 03:41:27:256 [W3C] WebDriverAgentRunner-Runner.app (19077) encountered an error (Failed to load the test bundle. If you believe this error represents a bug, please attach the result bundle at /Users/sagolGoru20/Library/Developer/Xcode/DerivedData/WebDriverAgent-gkbkvswlszzhhbevpokpwtrjdxxq/Logs/Test/Test-WebDriverAgentRunner-2021.02.16_22-41-22--0500.xcresult. (Underlying Error: **The bundle “WebDriverAgentRunner” couldn’t be loaded because it doesn’t contain a version for the current architecture. The bundle doesn’t contain a version for the current architecture. Try installing a universal version of the bundle.** dlopen_preflight(/Users/sagolGoru20/Library/Developer/Xcode/DerivedData/WebDriverAgent-gkbkvswlszzhhbevpokpwtrjdxxq/Build/Products/Debug-iphonesimulator/WebDriverAgentRunner-Runner.app/PlugIns/WebDriverAgentRunner.xctest/WebDriverAgentRunner): no suitable image found. Did find:
2021-02-17 03:41:27:256 [W3C] /Users/sagolGoru20/Library/Developer/Xcode/DerivedData/WebDriverAgent-gkbkvswlszzhhbevpokpwtrjdxxq/Build/Products/Debug-iphonesimulator/WebDriverAgentRunner-Runner.app/PlugIns/WebDriverAgentRunner.xctest/WebDriverAgentRunner: mach-o, but wrong architecture))
Here's the full appium log: https://gist.githubusercontent.com/fida10/44344b223874310cf296d38a95d4268f/raw/316855b619129680eeaa6519a446a436d0699cd6/failedLog.txt
I originally thought that this was an issue with xcode or WDA, but if that were the case, the tests would fail no matter how Appium was started, and as mentioned previously, the tests pass perfectly fine when Appium is started manually (via terminal), so it might be an issue with the PATH or environment variables upon execution from Java, not sure though.
Here is the code I am using to start the server programmatically:
HashMap<String, String> environment = new HashMap();
environment.put("PATH", "/usr/local/bin:" + System.getenv("PATH"));
AppiumDriverLocalService server = AppiumDriverLocalService
.buildService(new AppiumServiceBuilder()
.withEnvironment(environment)
.usingDriverExecutable(new File("//opt/homebrew/Cellar/node/15.8.0/bin/node"))
.withAppiumJS(new File("//Users/sagolGoru20/.npm-packages/lib/node_modules/appium/build/lib/main.js"))
.usingAnyFreePort()
.withArgument(GeneralServerFlag.SESSION_OVERRIDE)
.withLogFile(new File("//Users/sagolGoru20/Programming/JavaProjects/MavenProjects/MobileAutomationProjects/firstAppiumProject/appiumLog.txt"))
);
server.start();
As the appium log shows, the server seems to be started fine but then throws the above error, so I think the issue may be with how I'm building the AppiumDriverLocalService object.
I followed this tutorial in building AppiumDriverLocalService: https://appiumpro.com/editions/71-starting-an-appium-server-programmatically-using-appiumservicebuilder
Here is the project code. It's a simple project, I'm just clicking on an "Allow" button (line 26): https://gist.github.com/fida10/bec187a516fc32f907f97725263a7206
When I comment out the AppiumDriverLocalService server object (lines 46 to 58) and instead launch by uncommenting line 60, the test runs properly.
Any help would be greatly appreciated.
Was able to solve it by setting all options under "Build Active Architecture only" to "no", in XCode build settings. Details: https://github.com/appium/java-client/issues/1444#issuecomment-781078298
Hopefully this helps someone trying to run XCUITests on Mac devices with the new M1 chip.
I have a Java code to convert doc,docx to pdf using document4j it work fine on windows, but in linux I have this problem. Can I use this library on linux? Whats alternatives can I have?
The error is
java.io.IOException: Cannot run program "cmd" (in directory "/tmp/1542047549404-0"): error=2, No such file or directory
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048) ~[na:1.8.0_171]
2018-11-12 18:32:29.508 ERROR 10831 --- [pool-1-thread-1] c.d.c.msoffice.MicrosoftWordBridge : Unable to run script: /tmp/1542047549404-0/word_start184242440.vbs
java.io.IOException: Could not execute [cmd, /S, /C, ""/tmp/1542047549404-0/word_start184242440.vbs""] in /tmp/1542047549404-0.
at org.zeroturnaround.exec.ProcessExecutor.invokeStart(ProcessExecutor.java:936) ~[zt-exec-1.8.jar!/:na]
I think there are several reasons listed on their homepage why conversion cannot work under linux:
[...] the LocalConverter can only be run if:
The JVM is run on a MS Windows platform that ships with the Microsoft Scripting Host for VBS (this is true for all contemporary versions of MS Windows.
MS Word is installed in version 2007 or higher. PDF conversion is only supported when the PDF plugin is installed. The plugin is included into MS Word from Word 2010 and higher.
MS Word is not already running when the LocalConverter starts. This is in particularly true for MS Word instances that are run by another instance of LocalConverter. (As mentioned, be aware that this is also true for instances running on a different JVM or that are loaded by a different class loader.)
MS Word is properly activated and configured for the user running the JVM. MS Word does therefore not require any configuration on program startup or any other wizard.
When the JVM application which uses the LocalConverter is run as a service, note the information on using MS Word from the MS Windows service profile below.
For alternative approaches see How to convert MS doc to pdf
I'm using the following on Windows 7:
neo4j-community-1.9.2
Java 7 Update 25
I have Windows Firewall disabled.
When I start Neo4j.bat, both as Administrator and normally, I get the following message:
c:\Tools\neo4j\bin>Neo4j.bat
28/07/13 9:34:27 PM org.neo4j.server.AbstractNeoServer INFO: Setting startup tim
eout to: 120000ms based on -1
A blank Java console window pops up, no messages, then the window disappears after a minute or so.
When I go to http://localhost:7474/, I just get a server not found error.
If I try to install it as a service, the service wouldn't start.
Any ideas what I need to do to start Neo4j? I see here that Neo4j 1.9 does support Java 7:
http://blog.neo4j.org/2013/03/neo4j-19m05-released-wrapping-up.html
base.bat correctly points to windows-service-wrapper-5.jar, so not the windows-service-wrapper-*.jar problem that some people have had in the past. It would be helpful if it outputted an error message.
I just tried it with neo4j 2.0 milestone, and it didn't make any difference. The Java window pops up with no messages, http://localhost:7474/ gets a server not found error, then the Java window closes after a minute or two.
I added JAVA_HOME and JRE_HOME system variables, made no difference. I think I would get an error if Neo4j was not able to locate Java anyway.
I've fixed it.
With help from Neo4j's Google Group, I looked at the logs in data/logs/*.log and data/graph.db/messages.log, and found the following exception:
Caused by: java.rmi.server.ExportException: Port already in use: 1337; nested exception is:
java.net.BindException: Address already in use: JVM_Bind
Once I disabled my other service that uses that port, Neo4j's web admin at http://localhost:7474 worked. I then found out port 1337 is used by Neo4j's remote shell, I disabled it by adding enable_remote_shell = false to neo4j.properties, then I was able to have both Neo4j and my other service running.
I'm using the version 2.2.1 community edition of Neo4j on Windows 7, Java 1.8 update 45
In my case the log file messages.log was under default.graphdb directory. In there, you'll see the root cause of the problem.
I am using FireFox 18 with Selenium 2.29.0.
While running test exception occurs
Failed to connect to binary FirefoxBinary(C:\Program Files (x86)\Mozilla Firefox\firefox.exe) on port 7056; process output follows: null
It seems strange that this error seldom occurs. Let's say I have 20 tests in my class, the "failed to connect" error occurs in 2 tests sometimes 3 and sometimes it doesn't occur.
Can't figure out why is it happening. If this is some how version problem or something else, none of the test case should run.
If you have path variable at your environment variables not set..then set it to location of Firefox.exe....
Or you can explicitly mention path to firefox.exe a
File pathToFirefoxBinary = new File(browser);
FirefoxBinary firefoxbin = new FirefoxBinary(pathToFirefoxBinary);
driver = new FirefoxDriver(firefoxbin,null);
This should work..
Or u can go for upgradation to 2.31.0
I had exactly the same problem when i was using firefox 28.0, I solved it by downgrading Firefox version to 27.0.1
I have a jar application which process and converts file into csv file. I have made it to run in windows service using Java Service Wrapper. It got installed my jar application successfully when I run "InstallApp-NT. Bat" file and starts running my application when I run "app" command.
But when I try to start the service in services, its not starting and showing following message in dialog box<
Windows could not start the generic Preprocessor application on Local Computer. For more information, review the System Event Log. If this is a non-microsoft service, contact the service vendor, and refer to service-specific error code1
I have the system log file and it showing the below error message
System Event log:
--> Wrapper Started as Service
Java Service Wrapper Community Edition 3.3.2
Copyright (C) 1999-2009 Tanuki Software, Ltd. All Rights Reserved.
http://wrapper.tanukisoftware.org
Launching a JVM...
WrapperManager: Initializing...
WrapperSimpleApp:
WrapperSimpleApp: Encountered an error running main:
WrapperSimpleApp: java. Lang. NullPointerException
WrapperSimpleApp: at java. Util. Hashtable. Put(Hashtable. Java: 396)
WrapperSimpleApp: at java. Util. Properties. SetProperty(Properties. Java: 128)
WrapperSimpleApp: at java. Lang. System. SetProperty(System. Java: 701)
WrapperSimpleApp: at com. Dnb. Genericpreprocessor. Process. ProcessRunner. Main(Unknown Source)
WrapperSimpleApp: at sun. Reflect. NativeMethodAccessorImpl. Invoke0(Native Method)
WrapperSimpleApp: at sun. Reflect. NativeMethodAccessorImpl. Invoke(NativeMethodAccessorImpl. Java: 39)
WrapperSimpleApp: at sun. Reflect. DelegatingMethodAccessorImpl. Invoke(DelegatingMethodAccessorImpl. Java: 25)
WrapperSimpleApp: at java. Lang. Reflect. Method. Invoke(Method. Java: 585)
WrapperSimpleApp: at org. Tanukisoftware. Wrapper. WrapperSimpleApp. Run(WrapperSimpleApp. Java: 238)
WrapperSimpleApp: at java. Lang. Thread. Run(Thread. Java: 595)
<-- Wrapper Stopped
I don't think any error in application code because it running fine when run "app" command. Please help what I should now. Thanks in advance.
I am using the following code in com.dnb.genericpreprocessor.process.ProcessRunner class.
String projectHome = "D:\BL";
System.setProperty("project.home", projectHome);
System.setProperty("log.home",System.getenv("DBE")); ---> DBE is the envirinment variable I created in user variables.
When I run the application by giving app command... Its running the application by printing the environment value but showing the same error when I start it in service.
Answering your question update that you phrased as an answer, you need to ensure that the variable is in fact set in the specific environment where you are running the application. It appears that it is not. In fact, to avoid the NullPointerException, I would modify your code to something like:
String loghome = System.getenv("DBE");
if (loghome == null) {
// LOG A COMPLAINT that the environment variable is not set
loghome = "some reasonable default value";
}
System.setProperty("log.home", loghome);
so at least your application won't fail with an obtuse NPE if it is executed in the wrong environment.
Check com.dnb.genericpreprocessor.process.ProcessRunner if that is your code and see what data you are setting in System property. NullPointer is telling that the key or the value you passed is Null.
Check your wrapper.config; you need to have all the necessary jars in order, and each with their own index number (for some reason):
wrapper.java.classpath.1=../lib/wrapper.jar
wrapper.java.classpath.2=%JAVA_HOME%/lib/tools.jar
...
Just a first thought.
I am not familiar with the proprietary solution you are using, but it seems you somehow configured it wrong.
Looks like some parameter the wrapper should have is null and is propagating all the way up until the system is trying to set it as property.
Maybe you should put your 'DBE' enviroment in the system variables not user variables.
Windows service starts at system account.