public void SuperDragDrop() { var eventObj = document.parentWindow.@event as IHTMLEventObj2; //拖拽的是链接,在新窗口中打开链接 var url = (object)eventObj.dataTransfer.getData("URL") as string; //MessageBox.Show(url); if (!string.IsNullOrEmpty(url)) { //MessageBox.Show(url); ieInstance.Navigate2(url, BrowserNavConstants.navOpenInBackgroundTab); return; } //拖拽的是选择的文本,则用google搜索该文本 var text = (object)eventObj.dataTransfer.getData("TEXT") as string; if (!string.IsNullOrEmpty(text)) { if (text.StartsWith("http://", System.StringComparison.OrdinalIgnoreCase)) //未被识别的超链接 { ieInstance.Navigate2(text, BrowserNavConstants.navOpenInBackgroundTab); } else //待搜索的文本 { ieInstance.Navigate2(string.Format("http://www.google.com.hk/search?hl=zh-CN&q={0}", text), BrowserNavConstants.navOpenInBackgroundTab); } return; } return; }
public void openWebPage(string webpage) { object url = webpage; IE.Navigate2(ref url, ref empty, ref empty, ref empty, ref empty); this.WaitUntilReady(); }
//ie 프로세스 생성 private void makeIeProcess(string url) { /* * have to check resolution * basic resolution : 800 x 600 * */ url = checkUrl(macroString.Substring(macroString.IndexOf("=") + 1)); Console.WriteLine(url); if (ie == null) { ie = new InternetExplorer(); webBrowser = (SHDocVw.WebBrowser)ie; webBrowser.Visible = true; ie.Left = 0; ie.Top = 0; ie.Height = int.Parse(browserXSizeTextbox.Text); ie.Width = int.Parse(browserYSizeTextbox.Text); } //User-Agent: Mozilla / 5.0(Linux; U; Android 2.2) AppleWebKit / 533.1(KHTML, like Gecko) Version / 4.0 Mobile Safari/ 533.1" // "User-Agent: Mozilla/7.0(Linux; Android 7.0.0; SGH-i907) AppleWebKit/664.76 (KHTML, like Gecko) Chrome/87.0.3131.15 Mobile Safari/664.76 (Windows NT 10.0; WOW64; Trident/7.0; Touch; .NET4.0C; .NET4.0E; .NET CLR 2.0.50727; .NET CLR 3.0.30729; .NET CLR 3.5.30729; Tablet PC 2.0; rv:11.0) like Gecko" log.Debug("navigate2 start"); ie.Navigate2(url, null, null, null, null); log.Debug("navigate2 complete"); ie.Wait(); prevUrl = url; log.Debug("wait complete"); }
public static void openNewInternetExplorerTab(ref InternetExplorer ie, string url) { // Open the URL in a new tab of the given InternetExplorer instance ie.Navigate2(url, BrowserNavConstants.navOpenInNewTab, ref m, ref m, ref m); // Make InternetExplorer visible ie.Visible = true; }
public void GetServersFromWeb(InternetExplorer ie, bool visible) { if (!groupName.Equals("PPE")) { try { object Empty = 0; object URL = Index.CreateInstance().temcurl + "?query=ON&group=" + groupName; ie.Visible = visible; ie.Navigate2(ref URL, ref Empty, ref Empty, ref Empty, ref Empty); System.Threading.Thread.Sleep(5000); while (ie.Busy) { System.Threading.Thread.Sleep(1000); } IHTMLDocument3 document = (IHTMLDocument3)ie.Document; if (document != null) { HTMLTable queryTable = (HTMLTable)document.getElementById("query_table"); if (queryTable != null && queryTable.rows != null && queryTable.rows.length > 1) { servers = new List <Server>(); for (int i = 1; i < queryTable.rows.length; i++) { HTMLTableRow row = (HTMLTableRow)queryTable.rows.item(i, i); if (row != null && row.cells != null && row.cells.length > 4) { HTMLTableCell serverCell = (HTMLTableCell)row.cells.item(0, 0); HTMLTableCell travelServerCell = (HTMLTableCell)row.cells.item(4, 4); if (serverCell != null && serverCell.innerText != null && !serverCell.innerText.Equals("") && travelServerCell != null && travelServerCell.innerText != null && !travelServerCell.innerText.Equals("")) { foreach (string singleTravelServer in travelServerCell.innerText.Split(new char[] { ',' })) { servers.Add(new Server(serverCell.innerText, singleTravelServer)); } } } } } } } catch (Exception exception) { Console.WriteLine(exception.Message); } finally { updateDate = DateTime.Now; OnUpdated(EventArgs.Empty); } } }
private bool PushUrlToPolicyCenterWindow(string url) { InternetExplorer targetWindow = null; bool pushSuccessful = false; try { for (int i = 0; i < WindowsInstance.Count; i++) { var tempIe = WindowsInstance.Item(i) as InternetExplorer; if (!IsIeAndNamedWindow(tempIe, WindowName)) { continue; } targetWindow = tempIe; break; } if (targetWindow != null) { targetWindow.Navigate2(url, null, "_self", null, null); try { var hWnd = (IntPtr)targetWindow.HWND; TabActivator.ShowWindowAsync(hWnd, TabActivator.SW_SHOWMAXIMIZED); TabActivator.SetForegroundWindow(hWnd); new TabActivator(hWnd).ActivateByTabsUrl(url); } catch (Exception aex) { _logger.Warn("*** An error occurred. See details below. ***"); _logger.Error("*** {0} ***", aex.Message); _logger.Error("*** {0} ***", aex.StackTrace); } pushSuccessful = true; } } catch (Exception ex) { pushSuccessful = false; _logger.Warn("*** An error occurred. See details below. ***"); _logger.Error("*** {0} ***", ex.Message); _logger.Error("*** {0} ***", ex.StackTrace); } return(pushSuccessful); }
public static InternetExplorer openNewInternetExplorerInstance(string url) { // Create an InternetExplorer instance InternetExplorer ie = new InternetExplorer(); // Open the URL ie.Navigate2(url, ref m, ref m, ref m, ref m); // Make InternetExplorer visible ie.Visible = true; return(ie); }
public static void NavigateURL(string url, int expectedStatusCode = (int)HttpStatusCode.OK, int delay = 0, int pause = 0) { if (ie == null) { throw new InvalidOperationException("IEExtension.SetUpIE() not called, you might want to inherit from IETest"); } Thread.Sleep(delay); ie.Navigate2(url); Debug.WriteLine("---IIE--- NavigateURL.WaitOne(); ie.Busy=" + ie.Busy); are.WaitOne(RequestTimeoutMS); Thread.Sleep(pause); AssertStatusCode(expectedStatusCode); }
public void GoToURL(object URL, RadioButton rbB2C = null) { IE.Visible = true; IE.Navigate2(ref URL); //if (rbB2C != null && rbB2C.Checked == true) //{ // MessageBox.Show("Wait!!! Login and Go to Main page. And then press OK", "Please Login KPM"); //} WA.WaitPageLoading(IE); doc = (HTMLDocument)IE.Document; }
public static bool run(string sURL) { InternetExplorer oIE = (InternetExplorer)COMCreateObject("InternetExplorer.Application"); if (oIE != null) { object oEmpty = String.Empty; object oURL = sURL; oIE.Visible = true; oIE.Navigate2(ref oURL, ref oEmpty, ref oEmpty, ref oEmpty, ref oEmpty); } return(true); }
private void CarregaDados() { Metodo = "Login"; ie = new InternetExplorer() { Visible = false, }; ie.Navigate2(UrlLogin); ie.DocumentComplete += Ie_DocumentComplete; }
/// <summary> /// IEを起動する /// </summary> /// <returns></returns> private InternetExplorer StartUpIE(string inURL) { var IE = new InternetExplorer(); IE.Top = 0; IE.Left = 0; IE.Width = 1400; IE.Height = 1000; object URL = inURL; IE.Navigate2(ref URL); IEWait(IE); //ページ内の要素を書き換えるためには、ページが表示されるまで待つ必要あり return(IE); }
private void button1_Click(object sender, EventArgs e) { descricao = descricaoHJ.Text; ie = new InternetExplorer() { Visible = true, }; ie.Navigate2(UrlLogin); _before = AbrirNavegador.Entrada; _actionToRun = AbrirNavegador.Acao; _after = AbrirNavegador.Saida; ie.DocumentComplete += Ie_DocumentComplete; }
public static void LaunchNewPage(string url) { InternetExplorer internetExplorer = GetInternetExplorers().FirstOrDefault(); if (internetExplorer != null) { internetExplorer.Navigate2(url, 0x800); WindowsApi.BringWindowToFront((IntPtr)internetExplorer.HWND); } else { internetExplorer = new InternetExplorer(); internetExplorer.Visible = true; internetExplorer.Navigate2(url); WindowsApi.BringWindowToFront((IntPtr)internetExplorer.HWND); } }
private void NavigateNewTab(string url) { InternetExplorer ie = null; ShellWindows allBrowser = new SHDocVw.ShellWindows(); int browserCount = allBrowser.Count - 1; while (browserCount >= 0) { ie = allBrowser.Item(browserCount) as InternetExplorer; if (ie != null && ie.FullName.ToLower().Contains("iexplore.exe")) { ie.Navigate2(url, 0x1000); break; } browserCount--; } this.Close(); }
public void GetGroupsFromWeb(InternetExplorer ie, bool visible) { try { groups = new List <string>(); groups.Add("PPE"); object Empty = 0; object URL = Index.CreateInstance().temcurl; ie.Visible = visible; ie.Navigate2(ref URL, ref Empty, ref Empty, ref Empty, ref Empty); while (ie.Busy) { System.Threading.Thread.Sleep(1000); } IHTMLDocument3 document = (IHTMLDocument3)ie.Document; if (document != null) { HTMLSelectElement selGroups = (HTMLSelectElement)document.getElementById("group"); if (selGroups != null) { for (int i = 0; i < selGroups.length; i++) { HTMLOptionElement option = (HTMLOptionElement)selGroups.item(i, i); if (option.text != null && !option.text.Equals("")) { groups.Add(option.text); } } } } } catch (Exception exception) { Console.WriteLine(exception.Message); } finally { updateDate = DateTime.Now; OnUpdated(EventArgs.Empty); } }
public void SyncExplorer(string fullPath) { if ((_explorerWindow != null) && (string.IsNullOrEmpty(_filenameToSet))) { var filenameOnly = Path.GetFileName(fullPath); var requestedFolderPath = Path.GetDirectoryName(fullPath); var currentExplorerLocation = new Uri(_explorerWindow.LocationURL).LocalPath; // Check if Explorer is already in the correct folder if (requestedFolderPath.Equals(currentExplorerLocation, StringComparison.InvariantCultureIgnoreCase)) { SetExplorerSelection(filenameOnly); } else { // Have to wait for the folder (document) to be loaded in Explorer before accessing any of its functions _filenameToSet = filenameOnly; _explorerWindow.DocumentComplete += ExplorerWindow_DocumentComplete; _explorerWindow.Navigate2(requestedFolderPath); // task is completed in ExplorerWindow_DocumentComplete } } }
private void btnReplay_Click(object sender, System.EventArgs e) { try{ if (txtHTTPdetails.Text.Length<=0 || txtTargetHost.Text.Length<=0 || txtTargetPort.Text.Length<=0){ return; } showresults formres=null; detailedRequest_IE work = new detailedRequest_IE(); work=getHTTPdetails(txtHTTPdetails.Text,true); if (chkReplayIE.Checked){ //IE try{ if (ie.FullName.Length>1){ ie.Stop(); ie.Quit(); ie = new InternetExplorer(); } } catch{ ie = new InternetExplorer(); } ie.Visible=true; Thread.Sleep(300); ie.Navigate2(ref work.url, ref isnull, ref isnull, ref work.postdata, ref work.headers); } if (chkReplayFireFox.Checked){ //FF try{ if (FF.FullName.Length>1){ formres.Controls.Remove(FF); FF.Stop(); FF.Quit(); FF = new AxMOZILLACONTROLLib.AxMozillaBrowser(); ((System.ComponentModel.ISupportInitialize)(this.FF)).BeginInit(); FF.Location = new System.Drawing.Point(0, 0); FF.Size = new System.Drawing.Size(792, 541); formres.Controls.Add(FF); Thread.Sleep(300); } } catch{ formres = new showresults(); try{ formres.Text="FireFox Browser results"; FF = new AxMOZILLACONTROLLib.AxMozillaBrowser(); ((System.ComponentModel.ISupportInitialize)(this.FF)).BeginInit(); FF.Location = new System.Drawing.Point(0, 0); FF.Size = new System.Drawing.Size(792, 541); formres.Controls.Remove(formres.rtbResults); formres.Controls.Add(FF); formres.Show(); } catch {} } //hack - Firefox adds its own content length try{ work.headers=work.headers.ToString().Replace("Content-Length","Firefix").Replace("Content-length","Firefix"); FF.Navigate2(ref work.url, ref isnull, ref isnull, ref work.postdata, ref work.headers); } catch {} } } catch {} }
/// <summary> /// 生成本地预览 /// </summary> private void PreviewBtn_Click(object sender, EventArgs e) { try { if (string.IsNullOrEmpty(jsonValue)) { MessageBox.Show("请先识别试卷!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } IEClient = new InternetExplorer(); IEClient.Visible = true; IEClient.DocumentComplete += new DWebBrowserEvents2_DocumentCompleteEventHandler(IE_DocumentComplete); IEClient.Navigate2(Application.StartupPath + "\\html\\SubjectPrev.html"); } catch(Exception ex) { MessageBox.Show(ex.Message); } }
static void Main(string[] args) { // Note: The "local" URLs below can be achieved by adding entries to one's // hosts file (C:\Windows\System32\drivers\etc\hosts), similar to the following: // 127.0.0.1 www.seleniumhq-test.test // 127.0.0.1 www.seleniumhq- test-alternate.test // The "remote" URL can be any URL to a server not hosted on localhost. const string LocalBypassedUrl = "http://www.seleniumhq-test-alternate.test:2310/common/simpleTest.html"; const string LocalProxiedUrl = "http://www.seleniumhq-test.test:2310/common/simpleTest.html"; const string RemoteUrl = "http://webdriver-herald.herokuapp.com"; // To avoid logging all of the traffic put through the proxy, set to false. bool isLoggingDebugInfoFromProxy = true; string hostName = "127.0.0.1"; Console.WriteLine("Starting proxy instance"); StartProxyServer(hostName, isLoggingDebugInfoFromProxy); Console.WriteLine("Proxy started on {0}:{1}", hostName, server.ProxyEndPoint.Port); string proxySetting = string.Format("http={0}:{1}", hostName, server.ProxyEndPoint.Port); Console.WriteLine("Getting current proxy settings"); var originalProxySettings = GetSystemProxySettings(); Console.WriteLine("Generating custom proxy settings"); var customProxySettings = CreateCustomProxySettings(proxySetting, "www.seleniumhq-test-alternate.test"); Console.WriteLine("Launching Internet Explorer"); InternetExplorer ie = new InternetExplorer(); ie.Visible = true; Console.WriteLine("Setting proxy settings to custom settings"); SetSystemProxySettings(customProxySettings); Thread.Sleep(5000); Console.WriteLine("Navigating to bypassed URL (should not be proxied)"); ie.Navigate2(LocalBypassedUrl); Thread.Sleep(5000); Console.WriteLine("Navigating to local URL with hosts file alias (should be proxied)"); ie.Navigate2(LocalProxiedUrl); Thread.Sleep(5000); Console.WriteLine("Navigating to non-local URL (should be proxied)"); ie.Navigate2(RemoteUrl); Thread.Sleep(5000); Console.WriteLine("Restoring proxy settings to orignal settings"); SetSystemProxySettings(originalProxySettings); Console.WriteLine("Closing Internet Explorer"); ie.Quit(); Console.WriteLine("Shutting down proxy on {0}:{1}", server.ProxyEndPoint.Address.ToString(), server.ProxyEndPoint.Port); StopProxyServer(); Console.WriteLine("Proxy instance shut down"); Console.WriteLine(); Console.WriteLine("=================================="); Console.WriteLine("Resources requested through proxy:"); Console.WriteLine("----------------------------------"); Console.WriteLine(string.Join("\n", uris.ToArray())); Console.WriteLine("=================================="); Console.WriteLine(); Console.WriteLine("Press <enter> to quit"); Console.ReadLine(); }
void OpenIE(string url) { //ProcessStartInfo startInfo = new ProcessStartInfo("IExplore.exe"); //startInfo.Arguments = url; //Process process1 = new Process(); //process1.StartInfo = startInfo; //process1.Start(); InternetExplorer ie = new InternetExplorer(); ie.Visible = true; ie.Navigate2(url); }
public void ValidarTelaInicial() { Metodo = "PegarValor"; ie.Navigate2("https://restrito.cotemig.com.br/diario/boletim.php"); }
void Events_Ondragend(IHTMLEventObj e) { BrowserNavConstants n = BrowserNavConstants.navOpenInBackgroundTab; switch (NewTabGround) { case 1: n = BrowserNavConstants.navOpenInBackgroundTab; break; case 2: n = BrowserNavConstants.navOpenNewForegroundTab; break; case 3: if (e.clientY < preY) { n = BrowserNavConstants.navOpenNewForegroundTab; } else { n = BrowserNavConstants.navOpenInBackgroundTab; } break; case 4: if (e.clientY >= preY) { n = BrowserNavConstants.navOpenNewForegroundTab; } else { n = BrowserNavConstants.navOpenInBackgroundTab; } break; } //n = BrowserNavConstants.navOpenNewForegroundTab; //var eventObj = e as IHTMLEventObj2; //When drag a url. //var url = (object)eventObj.dataTransfer.getData("URL") as string; //MessageBox.Show(url.ToString()); if (!string.IsNullOrEmpty(url)) { ieInstance.Navigate2(url, n); return; } //When drag a text. //var text = (object)eventObj.dataTransfer.getData("TEXT") as string; if (!string.IsNullOrEmpty(text)) { if (text.StartsWith("http://") || text.StartsWith("https://")) { ieInstance.Navigate2(text, n); } else { ieInstance.Navigate2(string.Format(SearchString, System.Web.HttpUtility.UrlEncode(text)), n); } return; } return; }
public static string GetDBServer(string environment) { InternetExplorer IE = new InternetExplorer(); object Empty = 0; object URL = "http://bdtools.sb.karmalab.net/envstatus/envstatus.cgi"; IE.Visible = true; IE.Navigate2(ref URL, ref Empty, ref Empty, ref Empty, ref Empty); System.Threading.Thread.Sleep(10000); while (IE.Busy) { System.Threading.Thread.Sleep(100); } IHTMLDocument3 document = (IHTMLDocument3)IE.Document; HTMLSelectElement selGroups = (HTMLSelectElement)document.getElementById("group"); HTMLDivElement divSubmit = (HTMLDivElement)document.getElementById("submitbutton"); HTMLButtonElement btnSubmit = (HTMLButtonElement)divSubmit.firstChild; if (environment == null || environment == "") { selGroups.value = "CHE-RC01"; } else { selGroups.value = environment; } Console.WriteLine("environment: {0}", selGroups.value); btnSubmit.click(); System.Threading.Thread.Sleep(10000); while (IE.Busy) { System.Threading.Thread.Sleep(100); } HTMLDivElement divSitesTable = (HTMLDivElement)document.getElementById("sitestable"); string targetWebServerName = ""; foreach (HTMLDTElement cell in divSitesTable.getElementsByTagName("td")) { bool isServerName = false; bool containHIMS = false; HTMLDTElement webServerName = (HTMLDTElement)cell.firstChild; if (webServerName.innerText.Contains("CHELWEB")) { isServerName = true; foreach (HTMLAnchorElement link in cell.getElementsByTagName("a")) { if (link.innerText.Equals("everestadmintools.com")) { containHIMS = true; targetWebServerName = webServerName.innerText; Console.WriteLine("web server: {0}", webServerName.innerText); break; } } } if (isServerName && containHIMS) { break; } } HTMLAreaElement targetWebServerSpan = (HTMLAreaElement)document.getElementById(targetWebServerName); HTMLTableCell targetCell = (HTMLTableCell)targetWebServerSpan.parentElement.parentElement; HTMLTableCell dbServerName = (HTMLTableCell)targetCell.nextSibling.nextSibling.nextSibling.nextSibling; string targetDBServerName = dbServerName.innerText; Console.WriteLine("database server: {0}", targetDBServerName); IE.Quit(); return(targetDBServerName); }