WebBrowser local html file, flash not working? - c#

I am using a WinForm webbrowser, i load an local html file which contains and flash player that plays a video but the problem is that the player works but the video is not loaded.
When i open the html file in a browser it works fine.
Here is the code i am using:
string curDir = Directory.GetCurrentDirectory();
this.webBrowser1.Url = new Uri(String.Format("file:///{0}/Resources/streaming.html", curDir));
The file location is correct, is there anything i can do to solve the problem ?

Try explicitly disabling the following Browser Features for your WebBrowser-based app: FEATURE_LOCALMACHINE_LOCKDOWN, FEATURE_BLOCK_LMZ_OBJECT, FEATURE_BLOCK_LMZ_SCRIPT. You could reuse some code from here.

Related

Downloading file on anchor click

I having problem making a file download work when pushing a <a> with Puppeteer-sharp in headless mode.
I have this kind of html:
<div>
<button>Button</button>
</div>
In headless mode = FALSE, everything is working, pushing the anchor tack download the file to the browser download folder, and pushing the tag is also working.
but if I switch the mode to headless = TRUE, then the file is not downloaded, I very sure that puppeteer are clicking the tag as I get no error running the code. The button click is working. I tried search all my c-drive but I cannot find the file that is supposed to be downloaded anywhere. I tried taking some jpg dumps and all seams to work.
Any help on how to make it possible for Puppeteer-sharp to work in headless mode and still be able to download files when clicking a link?
I found a solution:
Adding this to the IPage object:
await page.Client.SendAsync("Page.setDownloadBehavior", new
{
behavior = "allow",
downloadPath = Path
});
made the file download also in headless mode.

How to download HTML code from WebView webpage?

I would like to know to know how to download HTML code from a webpage in Xamarin. The webpage is opened on a Android device and requires login, therefore it cannot be downloaded using a url link in WebClient. I am interested if the is a possibilty to download the HTML code from the opened webside, so that it can be used to notify me about changes in the webside.
My code to open the webside (then i need to log in):
void WebViewFunction()
{
webView1 = FindViewById<WebView>(Resource.Id.webView1);
webView1.Settings.JavaScriptEnabled = true;
webView1.SetWebViewClient(new Client());
webView1.LoadUrl($"https://www.strava.cz/Strava/Stravnik/Prihlaseni");
}
I have absolutely no idea how to do it since I am a beginner.
Thanks for your answer.

Downloaded files using WebClient.DownloadFile() do not work

So I've been trying to download a file from MediaFire using WebClient.DownloadFile(), but all files I download do not work properly. I've tried to download PDF files and PNG files, none of them open correctly in their respective software. I'm using this for a WinForms desktop application. I've already searched for multiple solutions but none of them apply to my situation.
This is the code I've used:
private void downloadFile(string url, string filename)
{
var client = new WebClient();
client.DownloadFile(url, filename);
}
I'm a begginer so any help is appreciated!
I found the solution myself with some help from Jimi.
I needed to find the link the page was using for the download process, not the link to the page itself. I did this by accessing the code of the page using the inspect tool and finding the direct link to the file, then using my previous method it worked just fine.

Selenium C# Test with Chrome Headless - Chrome File Upload Window not working

I have a test which uploads a profile image to the web application. In order to upload the image file, an upload button is clicked which opens a file upload window as shown in the screenshot below.
The test then sends keys of the image file path to the file upload window in order to upload the file. When the test is run in chrome headless mode, the file upload window is not found and the send keys step fails.
If the test is run in normal mode (without headless option) the test runs fine without any issue. What could be the problem? Is there any way to fix this? Following code is used to set focus and send keys to the browser file upload window.
var dialogHWnd = FindWindow("#32770", "Open"); // Title for modal. IE: "Choose File to Upload"
var setFocus = SetForegroundWindow(dialogHWnd);
SendKeys.SendWait(#picPath);
Thread.Sleep(5000); //wait
SendKeys.SendWait(#"{Enter}");
Reporter.LogTestStepForBugLogger(Status.Info, $"Sent keys {picPath} and Enter to upload the Profile Picture.");
With selenium, you can just sent the full path of the image to the input element that is responsible for the upload.
Check the html code and search for relevant probably with "hidden" attribute or something common for this upload section.
Then just use:
driver.findElement(by.xpath('input xpath or id ..').sendKeys('path of the image in your system');

XML file can't be saved in windows mobile

In simple way, I want to save some data in XML file when i tried this code it ran successfully but,unfortunately i didn't the file in the project folder or anywhere on my computer.When I changed the path also i didn't find it.
The following is the used code
string configFile = #"config.xml";
XmlDocument xml = new XmlDocument();
XmlElement element = xml.CreateElement("Configuration");
xml.AppendChild(element);
//---create the <LastAccess> element---
element = xml.CreateElement("LastAccess");
element.InnerText = DateTime.Now.ToString();
xml.DocumentElement.AppendChild(element);
//---create the <LastSearchString> element---
element = xml.CreateElement("LastSearchString");
element.InnerText = "sushi";
xml.DocumentElement.AppendChild(element);
xml.Save(configFile);
Can you help me in this problem please.
When I wrote this code and ran the application the file must be saved whatever where
XmlDocument xml = new XmlDocument();
XmlElement element = xml.CreateElement("First");
xml.AppendChild(element);
element = xml.CreateElement("Second");
element.InnerText = "LaLa";
xml.DocumentElement.AppendChild(element);
xml.Save(#"XML.xml");
and then i try this code as the file has been saved
element.InnerText = "LaLa";
xml.DocumentElement.AppendChild(element);
xml.Save(#"XML.xml");
I got that exception Could not find file '\XML.xml'.
please can you help me in this problem.
The emulator is, for all intents and purposes of this question, a completely separate device. It does not "share" any part of it's file system with the host PC, so there's no way to "browse" it's files (like the one you created" from the PC's Windows Explorer, or the standard file system APIs.
If you want access to the file from the PC, you need to use one of the following to retrieve it:
Configure the emulator to share a folder with the PC. This is don't in the options of the Emulator itself and allows you to "mount" a Host PC folder. That folder becomes the "\Storage Card" root folder in the emulator, so you'd have to change your code appropriately (i.e. save to "\storage card\config.xml")
Use a tool like Remote Registry Editor (in the Start menu under Visual Studio 22008 remote tools), connect to the emulator and download the file.
Use the Emulator Manager to "dock" the emulator so it shows up in ActiveSync/WMDC. When that occurs, a shell extension will show the device in Windows Explorer - though be aware that it is purely a shell extension. There is still no file API access to that system, so you could not write a desktop app that navigates to "My Device\MyFolder\MyFile.xml".

Categories