There are some things that I didn't find how to do using geckofx:
Get the URL of a clicked link.
Display print preview window.
Does this functionality exist in geckofx? If not, what's the best way
to achieve it in a C# project that uses GeckoWebBrowser to display html pages?
Thanks
To get url of clicked link you can use:
void domClicked(object sender, GeckoDomMouseEventArgs e)
{
if(geckoWebBrowser1.StatusText.StartsWith("http"))
{
MessageBox.Show(geckoWebBrowser1.StatusText);//forward status text string somewhere
}
}
To show print dialog box you can use:
geckoWebBrowser1.Navigate("javascript:print()");
OnNaviagted event should give you the link, and look for the print interfaces nsIPrintingPromptService::ShowPrintDialog in Geckofx.
geckoWebBrowser.url
That will give you the url at any point I believe where geckoWebBrowser is the name of the control, however as pointed out you'll be able to get it from the document completed and navigated events using e.url .
For printing, see this forum thread. Make sure to read it all before starting. Essentially you'll have to patch and recompile GeckoFX.
Related
Try to code with WPF. Currently I want to implement a simple webBrowser, and now I'm stuck. I want to get name of opened page (Every tab has name according to opened page), but I can't find the solution. In C# I can use this code:
TabControl.SelectedTab.Text = webBrowser.Url.Host.ToString();
But with WPF it doesn't work.
What is solution to find page name with WPF?
Please try like this,
TabControl.SelectedTab.Text = webBrowser1.Url.AbsoluteUri;
I want to get text from a website, but from a certain element, does any one have any clues?
From example the code I have to make text form a text box to a website textbox is
webBrowser1.Document
.GetElementById("MySchool_login")
.SetAttribute("value", textBox1.Text);
What you want to do is called as screen scrapping. You can use Watin for this. Or else you can use WebResponse and WebRequest to achieve this also.
I am writing Coded UI Test's for a web app. I am having problems such as I record actions using the test builder, however sometimes the button that is clicked has different information each time I run the test and as result VS can't find the button.
The html code never changes so what I want to do is find the button by its html code and click it that way.
For example on Google the path to the search button is
<button id="gbqfba" aria-label="Google Search" name="btnK" class="gbqfba"><span id="gbqfsa">Google Search</span></button>
How can I click this button using the code above or Alternativly using the XPath
//*[#id="gbqfba"]
Any help would be greatly appreciated.
adjust the Search Properties and Filter Properties.
Something like:
$('button span').each(function(){
If($(this).html() == "Google Search")
{
$(this).parent('button').click();
}
});
I found the answer, If you go to the UIMap.uitest file and click the method you have the problem with you can change the filter properties and the search properties to remove parts that are failing your test.
This will do the trick:
BrowserWindow.ExecuteScript("$('#gbqfba').click();");
In my web browser app for wp7, i have a textbox for the URL's(named as UrlTextBox), in that i don't need the http:// to be visible even when the page is navigating or navigated. I don't know how to hide a particular text in a textbox. If i try to omit the http:// permanently then there will an error in my app. Can anybody help me with this? Thanks in advance for your help!
I'd guess you're probably doing something like:
webBrowser.Navigate(urlTextBox.Text);
Instead you could just do:
webBrowser.Navigate("http://" + urlTextBox.Text);
Obviously with appropriate checks, etc.
OR
if (urlTextBox.Text.StartsWith("http://")
{
urlTextBox.Text = urlTextBox.Text.SubString(7);
}
I'm trying to teach myself C# and to start I'm trying to convert a program I originally wrote in Autoit.
I'm using a Windows Application Form and the program is suppose to take one or two links as input. Navigate to those to pages, grab some links from a table, then visit each of those pages to grab some content.
If only one link is entered it seems to go to that page and grab the links from a table like it is suppose to. If two links are entered it seems to only grab the links from the second table.
So if two links are passed this method
private void getPageURLList(string site1, string site2)
{
getPageURLList(site1);
getPageURLList(site2);
}
Calls the same method that gets called when there is only one link
private void getPageURLList(string site)
{
webBrowser.DocumentCompleted += createList;
webBrowser.Navigate(site);
}
I'm pretty sure the issue is "Navigate" is getting called a second time before createList even starts the first time.
The reason I am using WebBrowser is because these pages use Javascript to sort the links in the table so HTTPRequests and the HTMLAgilityPack don't seem to be able to grab those links.
So I guess my question is: How can I keep my WebBrowser from navigating to a new page until after I finish what I'm doing on the current page?
You have to make a bool variable to know when the first proccess has completed. And then start the other. Application.DoEvents() will help you.
Note that all this events run in the main thread.
In your documentcompleted event you do your link processing. At the end of the link processingyou tel the browser to navigate to the next url