i have to perform login activity in android application using appium java. my application is opening but login is not happening and getting below error in in appium server.
[AndroidDriver] Not cleaning generated files. Add clearSystemFiles capability if wanted.
Actual Result: Android application is opening but login activity not performed and giving below error:
Appium server is giving error like '[AndroidDriver] Not cleaning generated files. Add clearSystemFiles capability if wanted.'
Expected Result: Appium server should not get error and Login activity should also perform, once application is opened
package Automation;
import io.appium.java_client.AppiumDriver;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.remote.MobileCapabilityType;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import java.net.URL;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
public class AppiumTest2 {
AppiumDriver driver;
public void setup() throws Exception {
DesiredCapabilities Capabilities = new DesiredCapabilities();
Capabilities.setCapability("deviceName", "codeblaze");
Capabilities.setCapability("platforVersion", "7.0");
Capabilities.setCapability("platformName", "Adnroid");
Capabilities.setCapability("appPackage", "package name");
Capabilities.setCapability("appActivity", "activity name");
driver = new AndroidDriver(new URL("http://0.0.0.0:4723/wd/hub"), Capabilities);
}
public void tearDown() throws Exception {
driver.quit();
}
public void LogInWithInvalidEmail() {
WebElement emailTextField = (new WebDriverWait(driver,60)).until(ExpectedConditions.presenceOfElementLocated(By.id("etusername")));
emailTextField.sendKeys("Invalid Email");
WebElement passwordTextField = driver.findElement(By.id("etpassword"));
passwordTextField.sendKeys("Random Password");
WebElement loginButton = driver.findElement(By.id("lllogin"));
loginButton.click();
}
}
Appium server is giving error like '[AndroidDriver] Not cleaning generated files. Add clearSystemFiles capability if wanted.'
Expected Result: Appium server should not get error and Login activity should also perform, once application is opened
It should be as simple as:
Capabilities.setCapability(io.appium.java_client.remote.MobileCapabilityType.CLEAR_SYSTEM_FILES, true);
another issue might be connected with the typo in the platformName capability which should be Android, not Adnroid
It's better to stick to Page Object Model design pattern in Selenium and/or Appium tests, it will allow you to split UI representation from the test logic.
If above hints will not help - consider restarting the device/simulator.
More information: App was not copied, so not deleting
Related
So I've been trying to get my desired capabilities for a while and it's not working with the error of "failed to create session.
An unknown server-side error occurred while processing the command. Original error: Could not find a driver for platformName 'android'.
Please check your desired capabilities", I've tried a few other settings but nothing is working help me
{
"platformName":"andriod",
"appium:platformVersion": "11.0",
"appium:deviceName":"Saint", "appium:automationName":"capability",
"appium:app": "path"
}
Not much help with what you have provided , but session is not getting created can have multiple scenarios.
Check your Appium server is running.
Define your driver correctly either appium/androiddriver/iOSdriver..
Your capabilities list are not full , so please try to paste full error since it will be helpful.
Just replace these capabilities from your code with these name/caps
DesiredCapabilities desiredCapabilities = new DesiredCapabilities();
desiredCapabilities.setCapability("udid", udid);
desiredCapabilities.setCapability("platformVersion", platformVersion);
desiredCapabilities.setCapability("platformName", "Android");
desiredCapabilities.setCapability("appActivity", "<Your App activity>");
desiredCapabilities.setCapability("automationName","UiAutomator2");
}}
I have an app, it is very simple and have just one widget. It is working fine, however when I run integration test by calling:
$ flutter drive --target=test_driver/app.dart
I get the following error:
file:///Users/myuser/flutter/packages/flutter_test/lib/src/accessibility.dart:8:8: Error: Not found: 'dart:ui'
import 'dart:ui' as ui;
^
file:///Users/myuser/flutter/packages/flutter_test/lib/src/binding.dart:8:8: Error: Not found: 'dart:ui'
import 'dart:ui' as ui;
^
file:///Users/myuser/flutter/packages/flutter_test/lib/src/matchers.dart:8:8: Error: Not found: 'dart:ui'
import 'dart:ui' as ui;
^
file:///Users/myuser/flutter/packages/flutter_test/lib/src/matchers.dart:9:8: Error: Not found: 'dart:ui'
import 'dart:ui';
^
file:///Users/myuser/flutter/packages/flutter_test/lib/src/test_pointer.dart:12:1: Error: Not found: 'dart:ui'
export 'dart:ui' show Offset;
^
file:///Users/myuser/flutter/packages/flutter/lib/src/rendering/binding.dart:8:8: Error: Not found: 'dart:ui'
import 'dart:ui' as ui show window;
^
file:///Users/myuser/flutter/packages/flutter/lib/src/rendering/box.dart:6:8: Error: Not found: 'dart:ui'
import 'dart:ui' as ui show lerpDouble;
^
file:///Users/myuser/flutter/packages/flutter/lib/src/rendering/debug_overflow_indicator.dart:6:8: Error: Not found: 'dart:ui'
import 'dart:ui' as ui;
^
file:///Users/myuser/flutter/packages/flutter/lib/src/rendering/editable.dart:8:8: Error: Not found: 'dart:ui'
import 'dart:ui' as ui show TextBox;
^
file:///Users/myuser/flutter/packages/flutter/lib/src/rendering/error.dart:5:8: Error: Not found: 'dart:ui'
import 'dart:ui' as ui show Paragraph, ParagraphBuilder, ParagraphConstraints, ParagraphStyle, TextStyle;
^
Stopping application instance.
Driver tests failed: 254
Note that when I run the app from Android Studio, it runs successfully. But when I run from terminal using the command quoted above, the app shows a white screen and it doesn't move from there until I get the error on my terminal.
Assuming it's a path issue, like test_driver not finding flutter packages like dart:ui, how can I make sure test_driver knows where dart:ui is ?
Make sure that the import is set to this:
import 'package:test/test.dart';
instead of this:
import 'package:flutter_test/flutter_test.dart';
The integration tests can have no imports to your main App code or other flutter code that runs in the App - otherwise they will fail with your seen error.
Have a read of https://flutter.io/cookbook/testing/integration-test-introduction/ as this gives an example of integration tests with an app starting point that allows you to run setup code before your actual driver tests run if this is what you are looking to do. Otherwise don't use key values that use constants from your main code (as mentioned here http://cogitas.net/write-integration-test-flutter/).
This is old post, but I found another possible reason why test gave me this error:
When I was creating new Bloc class I created constructor with #required annotation and when I used Option+Enter for importing appropriate library, Android Studio imported 'package:flutter/cupertino.dart' library instead of 'package:meta/meta.dart' and that is the reason my unit test didn't start in the first place.
After importing correct library, all tests have passed!
Happy testing your code! :D
Here is the solution for adding these test cases:
In Android studio in the run dropdown you
select Edit Configurations
Press the + button and select Flutter test
Make sure the Test scope is All in file and point it at your test file.
You can now run the individual test file and also debug it in android studio by selecting this configuration in the run drop-down.
Remove all imports to package:flutter/... from the test driver's code, like:
import 'package:flutter/widgets.dart';
I was getting these erros because I was trying to import a widget on a test_driver file. I also got the same error if I try to use find.byWidget.
I was trying to import a widget or use find.byWidget because I wanted to check the existence of a widget on a screen.
These erros are pretty much similar to
The built-in library 'dart:ui' is not available on the stand-alone VM.
Then, in order to check the existence of a widget on screen in a test_driver file, I had to use find.byKeyValue. For example, given the following dummy widget, defined in a file within my app:
class MyDummyWidget extends StatelessWidget {
MyDummyWidget(): super(key: new Key('MyDummyWidget'));
#override
Widget build(BuildContext context) {
return Center();
}
}
To check if it is being displayed on screen, I define the following test within the test_driver:
void main() {
group('My tests', () {
FlutterDriver driver;
SerializableFinder myDummyWidget = find.byValueKey('MyDummyWidget');
setUpAll(() async {
driver = await FlutterDriver.connect();
});
tearDownAll(() async {
if (driver != null) {
driver.close();
}
});
test('check if MyDummyWidget is being displayed', () async {
await driver.waitFor(myDummyWidget);
});
});
}
Where the key definition is the required one in the first file, and then, the find.byValueKey and await driver ones are the essentials in the test file.
Don't simply run the test. It is running the pp virtually. So we can't import dart: UI. It'll give the error. Use command
flutter drive --target=test_driver/app.dart to test it.
In Android Studio, right-click on the test file in the Project tree and select "Run". You should see 2 options:
Make sure you select the second option: "tests in widget_test..."
If you select the first option you will see the Error: Not found: 'dart:ui' and you lose the option to make a selection from the Run context menu.
Finally, I got run widget tests in my app.
This soluction worked for me.
I found out why, I chose the first option instead of the flutter test. how silly I was, now removing this wrong test type from configuration and run with flutter test works now.
See the image about run in Android Studio
Just check that you don't have imports which load flutter packages.
In my case I had 'cupertino' package import from my file app_keys.dart which listed all keys in a format Key('<something>').
BUT!! UI tests use Key('<something>') constants for Finder but Integration tests - simple strings.
Reference
I was trying to do some action in the inbuilt Phone application, and trying to press 0 key (long press) but every time when I am trying to do, facing the issue:
org.openqa.selenium.WebDriverException: Returned value cannot be converted to WebElement: {ELEMENT=1}
Build info: version: '3.4.0', revision: 'unknown', time: 'unknown'
My code
package mobileapp.com.example;
import java.net.MalformedURLException;
import java.net.URL;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import io.appium.java_client.AppiumDriver;
import io.appium.java_client.TouchAction;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.remote.MobileCapabilityType;
public class Call {
AndroidDriver<WebElement> driver;
#BeforeClass
public void Setup() throws MalformedURLException {
DesiredCapabilities cap= new DesiredCapabilities();
cap.setCapability(MobileCapabilityType.DEVICE_NAME, "Fever");
cap.setCapability("platformVersion", "6.0");
cap.setCapability("platformName", "Android");
cap.setCapability("appPackage", "com.android.dialer");
cap.setCapability("appActivity", "com.android.dialer.DialtactsActivity");
//driver=new AndroidDriver<WebElement>(new URL("http://127.0.0.1:4723/wd/hub"), cap);
driver=new AndroidDriver<WebElement>(new URL("http://127.0.0.1:4723/wd/hub"), cap);
}
#Test
public void simpleTest() {
driver.findElement(By.id("com.android.dialer:id/floating_action_button")).click();
WebElement ele=driver.findElement(By.id("com.android.dialer:id/zero"));
TouchAction action=new TouchAction(driver);
action.longPress(ele);
ele.click();
}
}
I am using Appium version 1.4.16.1 and appium java client version was 5.0.4
The main issue is that you are using very old appium server and latest java client, so your issue is caused by incompatibility of client/server versions.
Update server to the 1.7.x
If locator is correct, it should work after update. Alternately you may use:
driver.pressKeyCode(AndroidKeyCode.KEYCODE_NUMPAD_0);
where driver is instance of AndroidDriver class
I am not able to use methods like isLocked(),closeApp(),isinstall()
I am not getting these options for ctrl + space after 'driver.'
Am I missing some library?
Please let me if more info required
import io.appium.java_client.android.AndroidDriver;
AndroidDriver driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"),cap);
Hi I'm trying to get a video running with vlcj on a mac.
I tried several things but everywhere there is something wrong.
The Programm is starting up, but there is no video playing. Does anyone know how to handle vlcj on a mac?
My intentions are to play a rtsp stream on a mac with java. I tried it first with opencv and now vlcj but didn't succed.
Are there any good examples how to do that on a mac or does anyone know why it is not working?
Thanks
Code:
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JFrame;
import javax.swing.SwingUtilities;
import javax.swing.Timer;
import uk.co.caprica.vlcj.binding.LibVlc;
import uk.co.caprica.vlcj.component.EmbeddedMediaPlayerComponent;
import uk.co.caprica.vlcj.runtime.RuntimeUtil;
import com.sun.jna.Native;
import com.sun.jna.NativeLibrary;
public class VideoExample {
private final EmbeddedMediaPlayerComponent mediaPlayerComponent;
public static void main(final String[] args) {
uk.co.caprica.vlcj.binding.LibC.INSTANCE.setenv("VLC_PLUGIN_PATH", "/Applications/VLC.app/Contents/MacOS/plugins", 1);
NativeLibrary.addSearchPath(RuntimeUtil.getLibVlcLibraryName(), "/Applications/VLC.app/Contents/MacOS/lib");
Native.loadLibrary(RuntimeUtil.getLibVlcLibraryName(), LibVlc.class);
SwingUtilities.invokeLater(new Runnable() {
#Override
public void run() {
new VideoExample(args);
}
});
}
private VideoExample(String[] args) {
JFrame frame = new JFrame("vlcj Tutorial");
mediaPlayerComponent = new EmbeddedMediaPlayerComponent();
frame.setContentPane(mediaPlayerComponent);
frame.setLocation(100, 100);
frame.setSize(500, 500);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
mediaPlayerComponent.getMediaPlayer().playMedia("/test.m4v");
}
}
Bug:
[main] INFO uk.co.caprica.vlcj.Info - vlcj: <version not available>
[main] INFO uk.co.caprica.vlcj.Info - java: 1.8.0_45 Oracle Corporation
[main] INFO uk.co.caprica.vlcj.Info - java home: /Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/jre
[main] INFO uk.co.caprica.vlcj.Info - os: Mac OS X 10.10.4 x86_64
[AWT-EventQueue-0] INFO uk.co.caprica.vlcj.binding.LibVlcFactory - vlc: 2.2.1 Terry Pratchett (Weatherwax), changeset 2.2.1-0-ga425c42
[AWT-EventQueue-0] INFO uk.co.caprica.vlcj.binding.LibVlcFactory - libvlc: /Applications/VLC.app/Contents/MacOS/lib/libvlc.dylib
JavaVM WARNING: JAWT_GetAWT must be called after loading a JVM
Exception in thread "AWT-EventQueue-0" java.lang.UnsatisfiedLinkError: Can't load JAWT
at com.sun.jna.Native.getWindowHandle0(Native Method)
at com.sun.jna.Native$AWT.getComponentID(Native.java:1879)
at com.sun.jna.Native.getComponentID(Native.java:253)
at uk.co.caprica.vlcj.player.embedded.videosurface.CanvasVideoSurface.attach(CanvasVideoSurface.java:76)
at uk.co.caprica.vlcj.player.embedded.DefaultEmbeddedMediaPlayer.attachVideoSurface(DefaultEmbeddedMediaPlayer.java:162)
at uk.co.caprica.vlcj.player.embedded.DefaultEmbeddedMediaPlayer.onBeforePlay(DefaultEmbeddedMediaPlayer.java:327)
at uk.co.caprica.vlcj.player.DefaultMediaPlayer.play(DefaultMediaPlayer.java:804)
at uk.co.caprica.vlcj.player.DefaultMediaPlayer.playMedia(DefaultMediaPlayer.java:265)
at uk.co.caprica.vlcj.player.DefaultMediaPlayer.playMedia(DefaultMediaPlayer.java:256)
at VideoExample.<init>(VideoExample.java:46)
at VideoExample.<init>(VideoExample.java:34)
at VideoExample$1.run(VideoExample.java:29)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:756)
at java.awt.EventQueue.access$500(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:709)
at java.awt.EventQueue$3.run(EventQueue.java:703)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:726)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
This is a well-known and well-documented issue with vlcj (and in fact other applications) on OSX with a JDK later than 1.6.
I know link-only answers are not the best, but there's way too much information on this problem to repeat here, so check https://github.com/caprica/vlcj/issues/205.
Essentially you can't use the embedded media player component since it relies on a heavyweight AWT component (a Canvas) to 'host' the video, and in JDK 1.7 and later on OSX there is no heavyweight AWT anymore.
So on OSX either use the so-called "direct" rendering approach with vlcj, or use JDK 1.6.
Thanks
Here is everything explained step by step
http://capricasoftware.co.uk/#/projects/vlcj/tutorial/direct-rendering
the rtsp stream works perfectly fine if you are ok with 3 seconds delay