Appium 2 version is no invoking via appium automation but old version is invoking - gradle

I have installed appium 2 version. If i start appium server via CLI command , i can see latest appium version . But when i start via APPIum+gradle+Selenium automation code, I'm getting wrong old version.
[Appium] Welcome to Appium v2.0.0-beta.53 [Appium] Non-default server
args: [Appium] { [Appium] address: '127.0.0.1' [Appium] } [Appium]
Appium REST http interface listener started on 127.0.0.1:4723
I'm using appium automation and code is like below
import io.appium.java_client.service.local.AppiumDriverLocalService;
import io.appium.java_client.service.local.AppiumServiceBuilder;
import io.appium.java_client.service.local.flags.GeneralServerFlag;
import org.slf4j.Logger; import org.slf4j.LoggerFactory;
public final class AppiumServerController {
private static final Logger LOG =
LoggerFactory.getLogger(AppiumServerController.class); private
static final AppiumDriverLocalService service =
buildService(
new AppiumServiceBuilder()
.withIPAddress("127.0.0.1")
.usingAnyFreePort()
.withArgument(GeneralServerFlag.SESSION_OVERRIDE)
.withArgument(GeneralServerFlag.LOG_LEVEL, "debug"));
static {
LOG.info("Print Default Data" + DataHelper.getEnvironment());
LOG.info(
"Print Default Data"
+ APPIUM_HOST
+ " "
+ APPIUM_LOG_LEVEL
+ " "
+ GeneralServerFlag.LOG_LEVEL
+ " "
+ IMPLICIT_WAIT_TIME); }
public static void startAppiumServer() {
// To start appium server
try {
service.start();
LOG.info("Appium server started successfully");
} catch (Exception e) {
e.printStackTrace();
} }
Sometime it's generating correct version but sometimes it's giving wrong version. Is there any way to specify the version in app in automation in Java?
[Appium] Welcome to Appium v1.22.3
[Appium] Non-default server args:
[Appium] address: 127.0.0.1
[Appium] port: 29548
[Appium] sessionOverride: true
[Appium] Appium REST http interface listener started on 127.0.0.1:29548

Related

Unable to create Appuim driver session despite having latest chrome driver and slf4j dependencies

I have the latest chrome driver installed, which fixed the issue for others that have encountered the same error. I am new to using Appium.
here is the error:
Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Response code 404. Message: The requested resource could not be found, or a request was received using an HTTP method that is not supported by the mapped resource
Host info: host: 'MallSoft.local', ip: '2601:1c2:0:3680:0:0:0:8406%en0'
Build info: version: '4.8.1', revision: '8ebccac989'
System info: os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.16', java.version: '1.8.0_301'
Driver info: io.appium.java_client.android.AndroidDriver
Command: [null, newSession {capabilities=[{appium:app=/Users/fieldemployee/IdeaProjects/FirstAppiumProject/src/main/resources/ApiDemos-debug.apk, appium:automationName=uiAutomator2, appium:deviceName=nexus_5, platformName=ANDROID, appium:udid=emulator-5554}], desiredCapabilities=Capabilities {app: /Users/fieldemployee/IdeaPr..., automationName: uiAutomator2, deviceName: nexus_5, platformName: ANDROID, udid: emulator-5554}}]
Capabilities {app: /Users/fieldemployee/IdeaPr..., automationName: uiAutomator2, deviceName: nexus_5, platformName: ANDROID, udid: emulator-5554}
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:148)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at io.appium.java_client.remote.AppiumProtocolHandshake.createSession(AppiumProtocolHandshake.java:133)
at io.appium.java_client.remote.AppiumProtocolHandshake.createSession(AppiumProtocolHandshake.java:102)
at io.appium.java_client.remote.AppiumCommandExecutor.createSession(AppiumCommandExecutor.java:194)
at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:262)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:543)
at io.appium.java_client.AppiumDriver.startSession(AppiumDriver.java:229)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:157)
at io.appium.java_client.AppiumDriver.<init>(AppiumDriver.java:80)
at io.appium.java_client.AppiumDriver.<init>(AppiumDriver.java:92)
at io.appium.java_client.android.AndroidDriver.<init>(AndroidDriver.java:117)
at CreateDriverSession.main(CreateDriverSession.java:25)
Process finished with exit code 1
here is my code in IntelliJ:
import io.appium.java_client.AppiumDriver;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.remote.MobileCapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
public class CreateDriverSession {
public static void main(String[] args) throws MalformedURLException {
DesiredCapabilities caps = new DesiredCapabilities();
caps.setCapability(MobileCapabilityType.PLATFORM_NAME, "Android");
caps.setCapability(MobileCapabilityType.DEVICE_NAME, "nexus_5");
caps.setCapability(MobileCapabilityType.AUTOMATION_NAME, "uiAutomator2");
caps.setCapability(MobileCapabilityType.UDID, "emulator-5554");
//for windows users
String appUrl = "/Users/fieldemployee/IdeaProjects/FirstAppiumProject/src/main/resources/ApiDemos-debug.apk";
//System.getProperty("user.dir") + File.separator + "src" + File.separator + "main"
//+ File.separator + "resources" + File.separator + "ApiDemos-debug.apk";
caps.setCapability(MobileCapabilityType.APP, appUrl);
URL url = new URL("http://0.0.0.0:4723/");
AppiumDriver driver = new AndroidDriver(url, caps);
}
}
here is the result in the Appium GUI:
[HTTP] No route found for /wd/hud/session
[HTTP] <-- POST /wd/hud/session 404 8 ms - 211
[HTTP]
[HTTP] Request idempotency key: e718b60f-1d53-4e4b-8ebb-ddaf41d23b43
[HTTP] --> POST /session
[HTTP] {"capabilities":{"firstMatch":[{}],"alwaysMatch":{"appium:app":"/Users/fieldemployee/IdeaProjects/FirstAppiumProject/src/main/resources/ApiDemos-debug.apk","appium:automationName":"uiAutomator2","appium:deviceName":"nexus_5","appium:udid":"emulator-5554","platformName":"android"}}}
As stated, I have the latest chrome driver and browser installed (latest as of the date on this post). My initial error was related to slf4j but adding the dependencies to pom resolved it. I have tried changing the url and removing the "/wd/hud/" as well.
Possibly you need to add /wd/hub at the end.
Solution
Instead of:
URL url = new URL("http://0.0.0.0:4723/");
you need to use:
URL url = new URL("http://localhost:4723/");
or
URL url = new URL("http:///127.0.0.1:4723/");
References
You can find a relevant detailed discussion in:
SessionNotCreatedException: Could not start a new session. Unable to parse remote response error using SeleniumGrid

How can i make local http request in flutter?

when i make access on website on endpoint "http://localhost/newsapp_api/public/api/authors"it's work without any problem,but when i try this in flutter it shows me a problem.
message error:E/flutter (24506): [ERROR:flutter/lib/ui/ui_dart_state.cc(186)] Unhandled Exception: SocketException: OS Error: Connection refused, errno = 111, address = localhost, port = 46873
codes:
authors_api.dart
import 'package:http/http.dart' as http;
import 'dart:convert';
import 'package:news_app/utilities/api_utilities.dart';
import 'package:news_app/models/author.dart';
class AuthorsAPI {
Future<List<Author>> fetchAllAuthors() async {
// ignore: deprecated_member_use
List<Author> authors = List<Author>();
String allAuthorsApi = base_api + all_authors_api;
var url = Uri.parse(allAuthorsApi);
var response = await http.get(url);
print(response.statusCode);
print("*****************");
print(response.body);
}
}
api_utilities.dart
String base_api = "http://localhost/newsapp_api/public/api/authors";
String all_authors_api = "/api/authors";
make sure that you are not using any VPN or proxy server
try to use http://127.0.0.1 instead of http://localhost
hope this solve your problem
Note that localhost does not work with the Android emulator which uses 10.0.0.2
To support both Web and Android emulator use the (local) IP address of the server
You can make the server running on localhost avalible on your device like this:
adb reverse tcp:3000 tcp:3000
Please note that you should replace 3000 with the port that you srever is running on.
And that's it! Now you can access localhost from your device.

Spring boot address and port number issue

I was looking for possible root cause of the problem reported here (SO thread) - Cannot start a Tomcat v9.0 server in eclipse.
While fiddling for above (unrelated to the thread above mentioned), accidentally, instead of
server.port=8080
I put below in my application.properties file
server.address=8080
When I tried to start server I kept getting this error before I realized the typo.
***************************
APPLICATION FAILED TO START
***************************
Description:
Web server failed to start. Port 8080 was already in use
When I replaced "address" with "port", all worked fine.
Question: Is it expected behavior or a known defect or a possible new defect? If its a new defect, where can I report it on Spring Community?
UPDATE
Per the comments on github issue tracker https://github.com/spring-projects/spring-boot/issues/21101, it is fixed now and the fix will be released in next release 2.2.7
Spring Boot was unable to bind the server to the invalid address 8080.
And the default message is
Web server failed to start. Port 8080 was already in use
You can try to set
server.addresss=9090
and you will get the same message.
The error message is just misleading.
The message is generated in PortInUseFailureAnalyzer
And the PortInUseException is thrown here:
public void start() throws WebServerException {
synchronized (this.monitor) {
if (this.started) {
return;
}
try {
addPreviouslyRemovedConnectors();
Connector connector = this.tomcat.getConnector();
if (connector != null && this.autoStart) {
performDeferredLoadOnStartup();
}
checkThatConnectorsHaveStarted();
this.started = true;
logger.info("Tomcat started on port(s): " + getPortsDescription(true) + " with context path '"
+ getContextPath() + "'");
}
catch (ConnectorStartFailedException ex) {
stopSilently();
throw ex;
}
catch (Exception ex) {
if (findBindException(ex) != null) {
throw new PortInUseException(this.tomcat.getConnector().getPort());
}
throw new WebServerException("Unable to start embedded Tomcat server", ex);
}
finally {
Context context = findContext();
ContextBindings.unbindClassLoader(context, context.getNamingToken(), getClass().getClassLoader());
}
}
}

XSockets. version 3.06 getting Net net::ERR_CONNECTION_REFUSED with wss://

I’m running into an issue getting wss:// to work on version 3.06 in production.
I’ve been able to get it working in a test environment locally (see test environment settings at the end).
If I used ws:// and not wss://, the production server works
In production I get the following error: net::ERR_CONNECTION_REFUSED
(Note: when I use ws://, I’ve switched over my test web site to http:// and not https://
Production environment:
2 separate Web servers running a web application (load balanced)
1 separate server running XSockets v3.06 (as a Windows Service)
All servers are in a sub domain:
a. Web server: web1.acme.com
b. Xsocket Server: commbus.acme.com
(Note: I’m not showing the real domain name here (acme))
All servers are using the same wildcard certificate “cn=*.acme.com”
All servers are behind a firewall.
I’ve tried using a ConfigurationSettings class with the following different constructors:
(Note: the 192.168.1.1 is not the real internal IP we use but it’s similar)
1) I used this option because it worked in the test environment
public class SecureConfig : ConfigurationSetting
{
public SecureConfig()
: base()
{}
}
2)
public SecureConfig()
: base(new Uri("wss://commbus.acme.com:4502"), new Uri("wss://192.168.1.1:4502"))
{
this.CertificateLocation = StoreLocation.LocalMachine;
this.CertificateSubjectDistinguishedName = "cn=*.acme.com";
}
3)
public SecureConfig()
: base(new Uri("wss://commbus.acme.com:4502"), new Uri("wss://192.168.1.1:4502"))
{
4)
public SecureConfig()
: base(new Uri("wss://commbus.acme.com:4502")
{}
5)
public SecureConfig()
: base(new Uri("wss://commbus.acme.com:4502")
{
this.CertificateLocation = StoreLocation.LocalMachine;
this.CertificateSubjectDistinguishedName = "cn=*.acme.com";
}
Test environment:
To verify that I can setup wss://. I’ve been able to do the following test:
1) Run IIS Express locally with HTTPS
2) Run the XSockets code in a console application
(Note: All XSockets code is in a separate library assembly and the same library assembly is used in both my test console application and production)
3) For the test I used the certificate “cn=localhost”
This worked fine if I used the following in a ConfiguationSetting Class:
public class SecureConfig : ConfigurationSetting
{
public SecureConfig()
: base()
{
}
}
Behavior I’ve notice with the testing site:
I would get the same error in production if I used the following contructors for the ConfigurationSettings class:
public SecureConfig()
: base(new Uri("wss://localhost:4502"))
{
}
Or
public SecureConfig()
: base(new Uri("wss://localhost:4502"))
{
this.CertificateLocation = StoreLocation.LocalMachine;
this.CertificateSubjectDistinguishedName = "cn=local";
}
I’m not sure what I’m missing.
I was able to get it working.
I had to load the certificate from the file system.
public class SecuritConfig: ConfigurationSetting
{
public SecureConfig():base(new Uri("wss://commbus.acme.com"), new Uri("wss://192.168.1.100"))
{
this.Certificate = new X509Certificate2("wildcard.acme.com.pfx", "pwd");
}
}

OSGi bundle installation using pax-exam issue

I'm trying to write spock pax exam extension, but figured out a problem with bundle installation using server mode.
Here is my code
void visitSpecAnnotation(RunPax annotation, SpecInfo sp) {
sp.addListener(new AbstractRunListener() {
private TestContainer container
#Override
void beforeSpec(SpecInfo spec) {
ExamSystem system = PaxExamRuntime.createServerSystem(
CoreOptions.options(
karafDistributionConfiguration("mvn:org.apache.servicemix/apache-servicemix/4.4.1-fuse-03-06/tar.gz", // artifact to unpack and use
"servicemix", // name; display only
"2.2.4")
.unpackDirectory(new File("target/paxexam/unpack/"))
.useDeployFolder(false),
//debugConfiguration("5005", true),
keepRuntimeFolder(),
configureConsole().ignoreLocalConsole(),
when(isEquinox()).useOptions(
editConfigurationFilePut(
KARAF_FRAMEWORK, "equinox"),
systemProperty("pax.exam.framework").value(
System.getProperty("pax.exam.framework")),
//systemProperty("osgi.console").value("6666"),
//systemProperty("osgi.console.enable.builtin").value("true")
),
logLevel(WARN),
mavenBundle("org.sdo.coding", "words", "1.0")
))
container = PaxExamRuntime.createContainer(system)
container.start()
Thread.sleep(100000)
def ant = new AntBuilder()
ant.sshexec(host: "localhost",
port: '8101',
username: "smx",
password: 'smx',
trust: "yes",
command: "list",
outputproperty: 'result',
knownhosts: '/dev/null')
def result = ant.project.properties.'result'
println "result is $result"
def installed = result =~ /(?m)^(.*Installed.*)$/
println "installed ${installed[0]}"
}
Even if i increase delay i cannot find my bundle installed. I can see that the option mavenBundle doesn't affect karaf start, because if i place wrong version or artifactId, pax won't notify me about it.
Anyone has any clue on this problem?

Resources