Appium Flutter Driver | capabilities.setCapability("automationName", "Flutter") fails - java

I have created an automation project to test a flutter app using appium flutter driver.
But I cannot use flutter driver.
My automation project does not detect automationName as flutter.
Even if I try driver.context("FLUTTER"); I get NoSuchContextException error.
service = AppiumDriverLocalService
.buildService(new AppiumServiceBuilder()
.usingDriverExecutable(new File("/usr/local/bin/node"))
.withAppiumJS(
new File("/usr/local/lib/node_modules/appium/build/lib/main.js"))
.withIPAddress("127.0.0.1").usingPort(4723));
service.start();
DesiredCapabilities capabilities = new DesiredCapabilities();
File appDir = new File(System.getProperty("user.dir")+"/app");
File app = new File (appDir,"app-debug.apk");
capabilities.setCapability(MobileCapabilityType.APP, app.getAbsolutePath());
capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, "Android");
capabilities.setCapability("automationName", "Flutter");
capabilities.setCapability("appPackage", "com.example.flutter_intellij_test");
capabilities.setCapability("appActivity","com.example.flutter_intellij_test.MainActivity");
driver = new AndroidDriver<MobileElement>(service.getUrl(), capabilities);
wait = new WebDriverWait(driver, 10);
find = new FlutterFinder(driver);

Make sure your Appium server version is above 1.6
There shouldn't be anything specific with Java client, just try to change your capabilities this way:
DesiredCapabilities capabilities = new DesiredCapabilities();
File appDir = new File(System.getProperty("user.dir")+"/app");
File app = new File (appDir,"app-debug.apk");
capabilities.setCapability("app", app.getAbsolutePath());
capabilities.setCapability("platformName", "Android");
capabilities.setCapability("automationName", "Flutter");
capabilities.setCapability("retryBackoffTime", "500");
capabilities.setCapability("deviceName", <value from `adb devices`>);
driver = new AndroidDriver<MobileElement>(service.getUrl(), capabilities);
Next time post Appium server log :)

Related

WebDriver to disable SEC_ERROR_UNKNOWN_ISSUER in Firefox

WebDriver opens browser window, but I get SEC_ERROR_UNKNOWN_ISSUER.
I tried to add this site as an exception in browser, but when new browser window opened I get the same message again instead of the website.
FirefoxProfile profile = new FirefoxProfile();
FirefoxOptions options = new FirefoxOptions();
profile.setAcceptUntrustedCertificates(true);
profile.setAssumeUntrustedCertificateIssuer(true);
options.setLogLevel(Level.ALL);
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
capabilities.setCapability(FirefoxOptions.FIREFOX_OPTIONS, options);
WebDriver driver = new FirefoxDriver(capabilities);
You need to set setAcceptInsecureCerts Capabilities as true
This simple code work for me :-
System.setProperty("webdriver.gecko.driver", "D:\\Workspace\\StackOverlow\\src\\lib\\geckodriver.exe");
DesiredCapabilities desiredCapabilities = new DesiredCapabilities();
desiredCapabilities.setAcceptInsecureCerts(true);
WebDriver driver = new FirefoxDriver(desiredCapabilities);
driver.get("https://self-signed.badssl.com/");
OR
System.setProperty("webdriver.gecko.driver", "D:\\Workspace\\StackOverlow\\src\\lib\\geckodriver.exe");
DesiredCapabilities desiredCapabilities = new DesiredCapabilities();
desiredCapabilities.setCapability("acceptInsecureCerts", true);
WebDriver driver = new FirefoxDriver(desiredCapabilities);
driver.get("https://self-signed.badssl.com/")
Change your gecko path in first line of code. Update gecko driver and firefox

Error while running appium code

I am new to appium. I am getting below error when i Run appium code in eclipse:
Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: Unable to create new remote session. desired capabilities = Capabilities [{app=D:\Workspace\Mobile\Apps\ATT\AT.apk, appPackage=com.atp.android, appActivity=Splash, appium-version=1.6.4, platformVersion=6.0, platformName=Android, deviceName=Test}], required capabilities = Capabilities [{}]
Code:
private static AndroidDriver driver;
public static void main(String[] args) throws MalformedURLException, InterruptedException {
AppiumDriver driver;
File classpathRoot = new File(System.getProperty("user.dir"));
File appDir = new File(classpathRoot, "/Apps/AST/");
File app = new File(appDir, "AT.apk");
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("appium-version", "1.6.4");
//capabilities.setCapability(CapabilityType.BROWSER_NAME, "");
capabilities.setCapability("deviceName", "Test");
capabilities.setCapability("platformVersion", "6.0");
capabilities.setCapability("platformName", "Android");
capabilities.setCapability("app", app.getAbsolutePath());
capabilities.setCapability("appPackage", "com.atp.android");
capabilities.setCapability("appActivity", "Splash");
driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
driver.manage().timeouts().implicitlyWait(80, TimeUnit.SECONDS);
Thread.sleep(10000);
driver.quit();
Selenium version is 3.4
Please help to resolve this issue. Thanks
You can try to comment the following two lines and see how does it work:
capabilities.setCapability("appPackage", "com.atp.android");
capabilities.setCapability("appActivity", "Splash");
since when you run test on a complicate app, it's hard to make sure the content of apppackage and app are set right. Appium will help you to find the correct content automatically instead.

iPhone automation - web testing

Every time I launch a script, instead of automating the login page, driver takes session from previous script. I am running the script on iPhone simulator. I am also resetting the device. Please refer the above code for more info,
ServerArguments serverArguments = new ServerArguments();
serverArguments.setArgument("--address", "127.0.0.1");
serverArguments.setArgument("--no-reset", false);
serverArguments.setArgument("--command-timeout", 2400);
serverArguments.setArgument("--local-timezone", true);
serverArguments.setArgument("--full-reset", true);
this.appiumServer = new AppiumServer(new File("/usr/local/bin/node"), new File("/usr/local/lib/node_modules/appium/build/lib/main.js"),serverArguments);
this.appiumServer.startServer();
I am using Genium framework for starting/stopping appium server.
I am setting the above capabilities in DesiredCapabilities class,
capabilities.setCapability("platformName", "iOS");
capabilities.setCapability("udid", udid);
capabilities.setCapability("browserName", "Safari");
if (!platformVersion.equals("")) {
capabilities.setCapability("platformVersion", platformVersion);
}
capabilities.setCapability("deviceName", deviceName);
capabilities.setCapability("autoWebview", true);
capabilities.setCapability("newCommandTimeout", 120);

How to override useragent in firefox browser on saucelabs

Saucelabs:-
https://saucelabs.com/
Am creating the firefox driver on saucelabs using the following:-
DesiredCapabilities capabilities = DesiredCapabilities.firefox();
capabilities.setCapability("version", "5");
capabilities.setCapability("platform", Platform.XP);
// Create the connection to Sauce Labs to run the tests
this.driver = new RemoteWebDriver(
new URL("http://YOUR_USERNAME:YOUR_ACCESS_KEY#ondemand.saucelabs.com:80/wd/hub"),
capabilities);
}
I want to use the mobile user agent using firefox driver. How can i do it.
Have you tried creating a new profile and setting the user agent string on the profile?
FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("general.useragent.override", "UA-STRING");
DesiredCapabilities capabilities = DesiredCapabilities.firefox();
capabilities.setCapability(FirefoxDriver.PROFILE, profile);

How to set Proxy setting for Chrome in Selenium Java

I am able to set proxy settings for Firefox as below.
org.openqa.selenium.Proxy proxy = new org.openqa.selenium.Proxy();
proxy.setProxyType(ProxyType.MANUAL);
proxy.setHttpProxy(CONFIG.getProperty("hostname"));
proxy.setSslProxy(CONFIG.getProperty("hostname"));
proxy.setFtpProxy(CONFIG.getProperty("hostname"));
proxy.setSocksUsername(CONFIG.getProperty("username"));
proxy.setSocksPassword(CONFIG.getProperty("password"));
FirefoxProfile fp = new FirefoxProfile();
fp.setProxyPreferences(proxy);
driver = new FirefoxDriver(fp);
builder = new Actions(driver);
bckdbrowser = new WebDriverBackedSelenium(driver, ConfigReader.ENVIRONMENT_URL);
But I need to setup for Chrome as well.. Can any one assist me how to do ?
Thanks
Raj
You can try using the DesiredCapabilities class, like this:
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
capabilities.setCapability("chrome.switches", Arrays.asList("--proxy-server=http://user:password#proxy.com:8080"));
WebDriver driver = new ChromeDriver(capabilities);
Try this code:
FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("network.proxy.type", ProxyType.AUTODETECT.ordinal());
WebDriver driver = new FirefoxDriver(profile);
here we have one more solution....it's worked for me

Categories

Resources