Хабр Курсы для всех
РЕКЛАМА
Практикум, Хекслет, SkyPro, авторские курсы — собрали всех и попросили скидки. Осталось выбрать!
WebPreferences ds = new WebPreferences();
ds.ProxyConfig = "myproxy:80";
using (WebSession session = WebCore.CreateWebSession(ds))
{
webControl1.Source = new Uri("http://google.com");
}
WbAws.LoadingFrameCompleted += OnLoadingFrameCompleted;
WbAws.Source = new Uri("http://google.com");
private void OnLoadingFrameCompleted(...)
{
if (webView == null || !webView.IsLive || webView.ParentView != null || !e.IsMainFrame)
return;
LoadingFrameCompleted -= OnLoadingFrameCompleted;
}
// returns Javascript XPath query string for getting a single element
public static string GetJsSingleXpathString(string xpath)
{
return
String.Format(
"document.evaluate(\"{0}\", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue", xpath);
}
// returns Javascript XPath query string for getting a collection of elements
public static string GetJsXpathString(string xpath)
{
return
String.Format(
"document.evaluate(\"{0}\", document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null)", xpath);
}
string linkJsXpath = GetJsSingleXpathString("//a[contains(@href, 'example.com')]");
dynamic link = (JSObject) webControl.ExecuteJavascriptWithResult(linkJsXpath);
if (link == null)
{
MessageBox.Show("No link found!");
return;
}
// do something with the element
string url = link.href;
MessageBox.Show(url);
void webControl1_CertificateError(object sender, CertificateErrorEventArgs e)
{
e.Ignore = true;
e.Handled = EventHandling.Modal;
}
Private Sub WebControl1_CertificateError(sender As Object, e As Awesomium.Core.CertificateErrorEventArgs) Handles WebControl1.CertificateError
e.Ignore = True
e.Handled = Awesomium.Core.EventHandling.Modal
End Sub
webControl.ExecuteJavascript("document.getElementById('passwordTextbox').value='password'");
dynamic tbox = (JSObject) webControl.ExecuteJavascriptWithResult("document.getElementById('passwordTextbox')");
if (tbox == null)
выкинуть исключение об ошибке и т.д.
tbox.value = "password";
JSObject tbox = webControl.ExecuteJavascriptWithResult("document.getElementById('passwordTextbox')");
if ((tbox == null) || !tbox.HasProperty("value"))
выкинуть исключение об ошибке и т.д.
tbox["value"] = "password";
Как подключить сторонний браузер в приложении на C#