public void Run(IBrowser browser, ManualResetEvent manualResetEvent, Journey journey) { var css = browser.FindElement("#PD2_Select") != null ? "#PD2_Select" : "#PD2a_Select"; browser.SelectValueFromDropdown(css, journey.Person1Details.Title.ToString().ToLower()); browser.EnterTextIntoElement("#FirstName", journey.Person1Details.FirstName); browser.EnterTextIntoElement("#Surname", journey.Person1Details.Surname); browser.EnterTextIntoElement("#EmailAddress", journey.Person1Details.EmailAddress); browser.EnterTextIntoElement("#AddressLine1", journey.Person1Details.DoorNumber); browser.EnterTextIntoElement("#PostCode", journey.Person1Details.Postcode); browser.ClickElementWithCss("#findAddressLink"); if (journey.SingleOrJoint == WhoPage.SingleOrJoint.Joint) { browser.SelectValueFromDropdown("#PD20a_Select", journey.Person2Details.Title.ToString().ToLower()); browser.EnterTextIntoElement("#PartnerFirstName", journey.Person2Details.FirstName); browser.EnterTextIntoElement("#PartnerSurname", journey.Person2Details.Surname); browser.EnterTextIntoElement("#PartnerEmailAddress", journey.Person2Details.EmailAddress); } browser.EnterTextIntoElement("#PhoneNumber", journey.Person1Details.PhoneNumber); if (browser.ElementIsVisible(".Contact_email")) { browser.ClickElementWithCss(".Contact_email"); browser.ClickElementWithCss(".Contact_telephone"); browser.ClickElementWithCss(".Contact_post"); } browser.ClickElementWithCss("#nextPageButton"); manualResetEvent.WaitOne(Timeout.Infinite); }
public void Run(IBrowser browser, ManualResetEvent pauseEvent, Journey journey) { browser.EnterTextIntoElement("#Password", "P@55w0rd"); if (browser.FindElement("#PasswordConfirmation") != null) { browser.EnterTextIntoElement("#PasswordConfirmation", "P@55w0rd"); } browser.ClickElementWithCss("#nextPageButton"); pauseEvent.WaitOne(Timeout.Infinite); }
public void Run(IBrowser browser, ManualResetEvent pauseEvent, Journey journey) { var selectedItem = journey.RequiresCriticalIllness ? IncludeCriticalIllnessButton : DoNotIncludeCriticalIllnessButton; browser.ClickElementWithCss(selectedItem); if (journey.RequiresCriticalIllness) { var criticalIllnessBox = browser.FindElement("#CriticalIllnessAmount"); criticalIllnessBox.Clear(); criticalIllnessBox.SendKeys(journey.CriticalIllnessAmount.ToString()); } browser.ClickElementWithCss(NextButtonId); pauseEvent.WaitOne(Timeout.Infinite); }
private void buttonRun_Click(object sender, EventArgs e) { // Twebst automation code for hosted WebBrowser control. // Attach to native IWebBrowser2 object. If this code runs in other thread than UI thread you need // to marshal IWebBrowser2 object; see CoMarshalInterThreadInterfaceInStream in MSDN // http://msdn.microsoft.com/en-us/library/windows/desktop/ms693316(v=vs.85).aspx IBrowser browser = core.AttachToNativeBrowser((SHDocVw.IWebBrowser2) this.webBrowser.ActiveXInstance); // Or you can attach directly to Win32 window handle. Reccomended if you automate WebBrowser // from another thread because you don't need to marshal any COM object. // IBrowser browser = core.AttachToHWND(this.webBrowser.Handle.ToInt32()); browser.Navigate("http://codecentrix.com/doc/playground.htm"); // Find "Email" editbox control. IElement elem = browser.FindElement("input text", "id=email"); elem.InputText("*****@*****.**"); // Find "Password" editbox control. elem = browser.FindElement("input text", "id=password"); elem.InputText("notarealpwd"); // Automate a list box. elem = browser.FindElement("select", "id=cntry"); elem.Select("Romania"); // Automate check box and radio. elem = browser.FindElement("input radio", "id=r3"); elem.Check(); elem = browser.FindElement("input checkbox", ""); elem.Check(); // Modify the HTML document. elem = browser.FindElement("div", "id=deev"); elem.nativeElement.innerText = "just changed"; // Automate inside iframe. elem = browser.FindElement("a", "uiName=Download"); elem.Click(); // !!!!!! ALERT: // Some features don't work with hosted WebBrowser yet: closePopup, upload controls, modal and modeless HTML dialog boxes. }
public IWebElement FindElement(string cssSelector) { return(_browser.FindElement(cssSelector)); }
public void Click(string locator) { _browser.FindElement(By.XPath(locator)).Click(); }
public BaseWebElement(IBrowser browser, By by) { _by = by; coreElement = () => browser.FindElement(_by); this.browser = browser; }