How to open a file dialog using javascript with CEF - chromium-embedded

I am learning CEF,and now I want to open a file dialog using my owner javascript code.Who can help me to solve it?

virtual void RunFileDialog(
FileDialogMode mode,
const CefString& title,
const CefString& default_file_path,
const std::vector<CefString>& accept_filters,
int selected_accept_filter,
CefRefPtr<CefRunFileDialogCallback> callback) = 0;

Related

UIAutomation FlaUI - Detect opening windows on application level

I am using FlaUI for test automation and it works fine so far. Now I am trying to detect opening windows and while plain UIAutomation offers to register an eventhandler for "AutomationElement.RootElement" I cannot find a way to translate this to FlaUI as it always expects an AutomationElement. I can only think of the MainWindow, but this changes with Splash, Login, Enviroment-Selections, etc.
This is what I have now, but it does not fire when I open a window:
Window win = app.GetMainWindow(automation, TimeSpan.FromSeconds(5));
UIA3AutomationEventHandler automationEventHandler = new UIA3AutomationEventHandler(win.FrameworkAutomationElement, automation.EventLibrary.Window.WindowOpenedEvent, TestAction);
automation.NativeAutomation.AddAutomationEventHandler(automation.EventLibrary.Window.WindowOpenedEvent.Id,automation.NativeAutomation.GetRootElement(), (Interop.UIAutomationClient.TreeScope)TreeScope.Descendants, null, automationEventHandler);
Following the working plain UIAutomation code:
Automation.AddAutomationEventHandler(WindowPattern.WindowOpenedEvent,
AutomationElement.RootElement,
TreeScope.Descendants,
someDelegate);
Any help would be highly appreciated! Thanks everybody!
FlaUI has a GetDesktop method on the automation object which is the RootElement. You should be able to register an event there.
With #Roemer' help I made it work. Thank you so much!
using (var automation = new UIA3Automation())
{
AutomationElement root = automation.GetDesktop();
UIA3AutomationEventHandler automationEventHandler = new UIA3AutomationEventHandler(root.FrameworkAutomationElement,
automation.EventLibrary.Window.WindowOpenedEvent, HandleClickOnceDialogs);
automation.NativeAutomation.AddAutomationEventHandler(automation.EventLibrary.Window.WindowOpenedEvent.Id,
root.ToNative(),
(Interop.UIAutomationClient.TreeScope)TreeScope.Descendants,
null, automationEventHandler);
}
private void HandleClickOnceDialogs(AutomationElement element, EventId id)
{
}

C# UWP accress to file, created by app, is denied

I am creating a C# UWP App, which creates files with broadFileSystemAccess capability.
Creating and writing to the file is no problem, but reading it fails with error message "Access to the path is denied even when I use storageFile.Path after writing it (so path is guaranteed to be correct and I can open the file in a text editor without problem).
Can anyone tell me, what I may can do to fix the problem?
Kind regards,
Wolfgang
Now I use following code to create a StorageFile, which can be read by my UWP app:
public static async Task<StorageFile> CreateStorageFileFromPath(string filepath)
{
string path = Path.GetDirectoryName(filepath);
string filename = Path.GetFileName(filepath);
var folder = await StorageFolder.GetFolderFromPathAsync(path);
return await folder.GetFileAsync(filename);
}
Kind regards,
Wolfgang

How to click on captured image using sikuli

I am new to Sikuli. I am Automating a web application that have option to upload a file.
When I click on upload button it opens a popup window.In that window I have to select a file. How I can do it using sikuli.
I am using linux operating system so I can't use AutoIT.
Below is my code which I am trying
public static void imageClick()
{
Screen s= new Screen();
try {
s.capture();
s.find("Desktop.png");
s.click("Desktop.png",0);
System.out.println("Desktop is selected");
} catch (FindFailed e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
Desktop.png is a image file which I kept in my project. first I am searching it then clicking on it.
Anyone can help me how I can achieve this. Any help will be highly appreciated.
Finally I done in in below way
First import sikuli jar file to your project
Capture the Image where you want to click and save it to some location
for Ex. /home/dev/Desktop/abc.png
Screen s = new Screen(); //Created the Object of screen class
s.click("/home/dev/Desktop/abc.png");
public static void imageClick()
{
Screen s= new Screen();
Pattern DesktpIcon = new Pattern("Desktop.png");
s.click(DesktpIcon);
System.out.println("Desktop is Clicked.");
}

Not able to downlad file using inappbrowser in Phonegap?

I Create an App where download a file from server in mobile, so I Use InAppBrowser plugin to open download page link, its working fine but i am not able to download file using my app, when i open download link in mobile browser its automatic start download.
please help me thanks in advance.
I think, its better to open system browser using inAppBrowser plugin for both the platform by using
window.open('http://apache.org', '_system', 'location=yes');
using this you can easily download.
InAppBrowser doesn't allow download. You will need to modify plugin to allow it for downloading.
For android, inside platforms\android\src\org\apache\cordova\inappbrowser
method name private void navigate(String url) {
include
this.inAppWebView.setDownloadListener(new DownloadListener() {
public void onDownloadStart(String url, String userAgent,
String contentDisposition, String mimetype,
long contentLength) {
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
cordova.getActivity().startActivity(i);
}
});
before this line this.inAppWebView.requestFocus();
again same code in the method public void run() {
after this segment
if (clearAllCache) {
CookieManager.getInstance().removeAllCookie();
} else if (clearSessionCache) {
CookieManager.getInstance().removeSessionCookie();
}
inAppWebView.loadUrl(url);
in your .java file inside onCreate
appView.setDownloadListener(new DownloadListener() {
public void onDownloadStart(String url, String userAgent,
String contentDisposition, String mimetype,
long contentLength) {
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
startActivity(i);
}
});
Don't know about iOS

How can i save files in the phone accessible by several apps?

I try to develop several WP8 apps using the same credentials for all(same user and password).So if the user choose to change his credentials he does only once in one app and it will change for all.
Until now i used Isolatedstorage to save the credentials(as shown below) but im wondering if the files would be accessible by all the apps...i guess they would not.
So what solution do you have ?
thanks for your help
public static void SaveToFile(byte[] Encryptedfile, string FileName)
{
using (var SaveApplicationFile = IsolatedStorageFile.GetUserStoreForApplication())
{
SaveApplicationFile.DeleteFile(FileName);
using (IsolatedStorageFileStream fileAsStream = new IsolatedStorageFileStream(FileName, System.IO.FileMode.Create, FileAccess.Write, SaveApplicationFile))
{
using (Stream writer = new StreamWriter(fileAsStream).BaseStream)
{
writer.Write(Encryptedfile, 0, Encryptedfile.Length);
}
}
}
}
You can't access IsolatedStorage of other App.
Nor you can't save on SD card.
Maybe consider using Skydrive or other exteral storage.
Another idea, I'm thinking about - maybe you can use MediaLibrary and Save Picture there. And use this picture as a container for some data - maybe using Steganography ;)

Resources