-
-
Notifications
You must be signed in to change notification settings - Fork 766
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
When building a AppiumDriverLocalService, there is a Port number missmatch when providing --port argument #521
Comments
It seems as these server flags gets a special treatment: Would modifying the /**
* @param argument is an instance which contains the argument name.
* @param value A non null string value. (Warn!!!) Boolean arguments have a special moment:
* the presence of an arguments means "true". At this case an empty string
* should be defined.
* @return the self-reference.
*/
public AppiumServiceBuilder withArgument(ServerArgument argument, String value) {
String argName = argument.getArgument().trim();
if (argName.equals("--port") || argName.equals("-p")) {
usingPort(Integer.valueOf(value));
} else if (argName.equals("--address") || argName.equals("-a")) {
withIPAddress(value);
} else if (argName.equals("--log") || argName.equals("-g")) {
withLogFile(new File(value));
} else {
serverArguments.put(argName, value);
}
return this;
} |
@alexander-poulikakos
Thse is the set of methods provided by DriverService (except As I can read the log there is another problem
That means that the service was started successfully (!!!).
Do you see the difference? This is because it considers that the port was not provided so it uses the default value (4723) Actually current implementation does same things as you are going to propose. It adds port, log file and ip to arguments. |
thanks for your reply @TikhomirovSergey. My use case is that I am reading the arguments from a properties file, something like this:
and I would like to set them in a generic way for all arguments. Not make special cases for some of the arguments. Since the API allows any argument to be set through the ´withArgument(...)´ method, then it should work for all arguments, including For example, a unit test like below should pass. Currently it is not. @Test public void checkAbilityToStartServiceWithPortUsingFlags() throws Exception {
String port = "8996";
String expectedUrl = String.format("http://0.0.0.0:%s/wd/hub", port);
AppiumDriverLocalService service = new AppiumServiceBuilder()
.withArgument(() -> "--port", port)
.build();
String actualUrl = service.getUrl().toString();
assertEquals(expectedUrl, actualUrl);
} The problem is that the ´DriverService´ does not get aware of the new port when using ´withArgument(() -> "--port", "...")´ method.
No, that is not the same thing. What I propose is to make ´DriverService´ aware of the new port when using ´withArgument(...)´ method. |
@alexander-poulikakos Now I got your problem. Ok. You can propose the PR. My remark: Please use |
It was improved. It is going to be published soon. |
Just a minor comment: This calls the String argName = argument.getArgument().trim().toLowerCase(); So no need to call String argName = argument.getArgument().trim().toLowerCase();
if ("--port".equalsIgnoreCase(argName) || "-p".equalsIgnoreCase(argName)) {
usingPort(Integer.valueOf(value));
} else if ("--address".equalsIgnoreCase(argName) || "-a".equalsIgnoreCase(argName)) {
withIPAddress(value);
} else if ("--log".equalsIgnoreCase(argName) || "-g".equalsIgnoreCase(argName)) {
withLogFile(new File(value));
} else {
serverArguments.put(argName, value);
} Would be cleaner if String argName = argument.getArgument().trim().toLowerCase();
if ("--port".equals(argName) || "-p".equals(argName)) {
usingPort(Integer.valueOf(value));
} else if ("--address".equals(argName) || "-a".equals(argName)) {
withIPAddress(value);
} else if ("--log".equals(argName) || "-g".equals(argName)) {
withLogFile(new File(value));
} else {
serverArguments.put(argName, value);
} |
ok. Will improve that. |
I'm closing this ticket. |
Description
When providing the port number via
withArgument("--port", "8998")
method, there becomes a miss match in ports, i.e. server starts on one port, while java_client tries to connect to another port. In below code example/stackTrace The Appium server is started on port 8998, but the java_client tries to connect to the default port "4723" and times out with an exception.As can be seen in below stacktrace the port number is added twice in the node arguments.
The given Node.js executable: /usr/local/Cellar/node/5.5.0/bin/node Arguments: [/usr/local/lib/node_modules/appium/build/lib/main.js, --port, 4723, --address, 0.0.0.0, --port, 8998]
Environment
Code To Reproduce Issue [ Good To Have ]
Ecxeption stacktraces
The text was updated successfully, but these errors were encountered: