예제 #1
0
        /// <summary>
        /// NavigateMenuItems - Use 'NavigateMenuItemsParams' to pass parameters into this method.
        /// </summary>
        public void NavigateMenuItems(string webAppUrl)
        {
            #region Variable Declarations
            HtmlHyperlink uIProductsHyperlink  = this.UIBingInternetExplorerWindow.UIHomePageCRMDocument.UIProductsHyperlink;
            HtmlHyperlink uICustomersHyperlink = this.UIBingInternetExplorerWindow.UIIndexCRMDocument.UICustomersHyperlink;
            HtmlHyperlink uIRegisterHyperlink  = this.UIBingInternetExplorerWindow.UIIndexCRMDocument1.UIRegisterHyperlink;
            HtmlHyperlink uILoginHyperlink     = this.UIBingInternetExplorerWindow.UIRegisterCRMDocument.UILoginHyperlink;
            HtmlHyperlink uICRMHyperlink       = this.UIBingInternetExplorerWindow.UILoginCRMDocument.UICRMHyperlink;
            #endregion

            // Go to web page 'http://localhost:5555/' using new browser instance

            //this.UIBingInternetExplorerWindow.LaunchUrl(new System.Uri(this.NavigateMenuItemsParams.UIBingInternetExplorerWindowUrl));

            this.UIBingInternetExplorerWindow.LaunchUrl(new System.Uri(webAppUrl));
            // Click 'Products' link
            Mouse.Click(uIProductsHyperlink);

            // Click 'Customers' link
            Mouse.Click(uICustomersHyperlink);

            // Click 'Register' link
            //Mouse.Click(uIRegisterHyperlink);

            // Click 'Log in' link
            //Mouse.Click(uILoginHyperlink);

            // Click 'CRM' link
            Mouse.Click(uICRMHyperlink);
        }
 /// <summary>
 /// Searches for the name of the invoice
 /// </summary>
 private HtmlHyperlink FindInvoiceName(string innerLink)
 {
     var list = this.UIXeroInvoicesInternetWindow.UIXeroInvoicesDocument;
     var hyperlink = new HtmlHyperlink(list);
     hyperlink.SearchProperties.Add(HtmlHyperlink.PropertyNames.InnerText, innerLink, PropertyExpressionOperator.EqualTo);
     return hyperlink;
 }
예제 #3
0
        public void OpenCashierArea()
        {
            HtmlHyperlink cashier = new HtmlHyperlink(bw);

            cashier.SearchProperties.Add(HtmlHyperlink.PropertyNames.Id, "cashier");
            Mouse.Click(cashier);
        }
예제 #4
0
        public void HyperlinkTextClick(string innertext)
        {
            HtmlHyperlink a = new HtmlHyperlink(Doc);

            a.SearchProperties[HtmlHyperlink.PropertyNames.InnerText] = innertext;
            Mouse.Click(a);
        }
예제 #5
0
        /// <summary>
        /// Execute the Html navigation command.
        /// </summary>
        public void NavigateToHtmlHyperlink(HtmlHyperlink hyperlink)
        {
            if (hyperlink.TargetName.Length == 0)
            {
                return;
            }

            bool bFoundTarget = false;

            if (hyperlink.TargetName[0] == '#')
            {
                string href = hyperlink.TargetName.Substring(1, hyperlink.TargetName.Length - 1);
                if (KeyGenerator.Instance.CanConvertVModellIDToGuid(href))
                {
                    Guid         id           = KeyGenerator.Instance.ConvertVModellIDToGuid(href);
                    ModelElement modelElement = this.Store.ElementDirectory.FindElement(id);
                    if (modelElement != null)
                    {
                        bFoundTarget = true;

                        SelectedItemsCollection col = new SelectedItemsCollection();
                        col.Add(modelElement);
                        EventManager.GetEvent <SelectionChangedEvent>().Publish(new SelectionChangedEventArgs(this, col));
                    }
                }
            }

            if (!bFoundTarget)
            {
                System.Windows.MessageBox.Show(hyperlink.TargetName);
            }
        }
        public void Mouse_click_will_fail_because_hidden_link_is_matched_instead_of_visible_link()
        {
            // Playback.PlaybackSettings.SmartMatchOptions = SmartMatchOptions.None; // tried Sudhish Mathuria's suggestion

            var example2Path = Path.Combine(TestContext.TestDeploymentDir, "example2.htm");

            var window = BrowserWindow.Launch(example2Path);

            var document = new HtmlDocument(window);
            document.FilterProperties[HtmlDocument.PropertyNames.Title] = "2ad6de55-75f1-403f-8fcb-1d5defac9786";

            var visibleLink = new HtmlHyperlink(document);
            visibleLink.SearchProperties[HtmlHyperlink.PropertyNames.InnerText] = "Hello";

            // ONLY FIND VISIBLE CONTROLS !
            visibleLink.SearchConfigurations.Add(SearchConfiguration.VisibleOnly);

            var allMatches = visibleLink.FindMatchingControls();
            Assert.AreEqual(2, allMatches.Count, "Should be two matching.");

            visibleLink.Find(); // THIS SHOULD BE THE VISIBLE ONE

            Debug.WriteLine("BoundingRectangle: " + visibleLink.BoundingRectangle);
            Assert.IsTrue(visibleLink.BoundingRectangle.Width > 0, "Width should positive.");
            Assert.IsTrue(visibleLink.BoundingRectangle.Height > 0, "Height should positive.");

            Mouse.Click(visibleLink);
        }
예제 #7
0
        public void LogOut()
        {
            var link = new HtmlHyperlink(navbar);

            link.SearchProperties.Add(HtmlHyperlink.PropertyNames.InnerText, "Log Out");
            Mouse.Click(link);
        }
예제 #8
0
        public void CodedUITestMethod1()
        {
            BrowserWindow browser = BrowserWindow.Launch(new Uri("http://*****:*****@gmail.com");

            HtmlEdit Password_txtbox = new HtmlEdit(browser);

            Password_txtbox.SearchProperties.Add(HtmlEdit.PropertyNames.Id, "Password");
            Password_txtbox.SetFocus();
            Keyboard.SendKeys("144685");

            HtmlEdit ConPassword_txtbox = new HtmlEdit(browser);

            ConPassword_txtbox.SearchProperties.Add(HtmlEdit.PropertyNames.Id, "ConfirmPassword");
            ConPassword_txtbox.SetFocus();
            Keyboard.SendKeys("144685");
        }
예제 #9
0
 public MainAppWindow(MicrosoftDynamics365Window bw)
 {
     m_bw                      = bw;
     m_salesHyperlink          = m_bw.DashboardsSalesActivDocumen.TabHomePane.SalesHyperlink;
     m_projectServiceHyperlink = m_bw.DashboardsSalesActivDocumen.ProjectServiceHyperlink;
     m_projectGanttHyperlink   = m_bw.DashboardsSalesActivDocumen.ProjectGanttHyperlink;
 }
예제 #10
0
        // получение ссылки создания нового пользователя
        public HtmlHyperlink CreateOneHere()
        {
            HtmlHyperlink link = new HtmlHyperlink(browser);

            link.SearchProperties["class"] = "signupLink";
            return(link);
        }
예제 #11
0
        /// <summary>
        /// VerifyMyMetricsPageWorks
        /// </summary>
        public void VerifyMyMetricsPageWorks()
        {
            #region Variable Declarations
            HtmlDiv       uICatchAllPane = this.UIMSNcomHotmailOutlookWindow.UIMSNcomHotmailOutlookDocument.UIEbAd32190459_billboaFrame.UIHTML5Billboard88x31tDocument.UICatchAllPane;
            HtmlIFrame    uIEbAd32190459_billboaFrame = this.UIMSNcomHotmailOutlookWindow.UIMSNcomHotmailOutlookDocument.UIEbAd32190459_billboaFrame;
            HtmlHyperlink uIMyMetricsHyperlink        = this.UIMSNcomHotmailOutlookWindow.UIMercuryHealthGroupMeDocument.UIMyMetricsHyperlink;
            #endregion

            // Set flag to allow play back to continue if non-essential actions fail. (For example, if a mouse hover action fails.)
            Playback.PlaybackSettings.ContinueOnError = true;

            // Mouse hover 'catchAll' pane at (1, 1)
            Mouse.Hover(uICatchAllPane, new Point(1, 1));

            // Mouse hover 'ebAd32190459_billboard_iframe_32190459_93048926593...' frame at (1, 1)
            Mouse.Hover(uIEbAd32190459_billboaFrame, new Point(1, 1));

            // Failed to record the object corresponding to this action.

            // Reset flag to ensure that play back stops if there is an error.
            Playback.PlaybackSettings.ContinueOnError = false;

            // Click 'My Metrics' link
            Mouse.Click(uIMyMetricsHyperlink, new Point(72, 39));
        }
예제 #12
0
        public void MotoCreateSiteRenewal(string policyNumber, string renewalPremium, string insurer = "")
        {
            HtmlHyperlink uICreateaMotorTestReneHyperlink =
                map.UIInsurEcomSystemMaintWindow.UILeftbarFrame.UIInsurEcomLeftbarDocument.UIDivRenewalsPane.UICreateaMotorTestReneHyperlink;
            HtmlComboBox    uiInsurerIdComboBox          = map.UIInsurEcomSystemMaintWindow.UIContentFrame.UIInsurEcomMainPageDocument.UIInsurerIDComboBox;
            HtmlEdit        uITxtPolicyNumberEdit        = map.UIInsurEcomSystemMaintWindow.UIContentFrame.UIInsurEcomMainPageDocument.UITxtPolicyNumberEdit;
            HtmlEdit        uITxtAutoLapseDateEdit1      = map.UIInsurEcomSystemMaintWindow.UIContentFrame.UIInsurEcomMainPageDocument.UITxtAutoLapseDateEdit1;
            HtmlInputButton uICreateRecordButton         = map.UIInsurEcomSystemMaintWindow.UIContentFrame.UIInsurEcomMainPageDocument.UICreateRecordButton;
            HtmlEdit        uITxtPremiumEdit             = UIInsurEcomSystemMaintWindow.UIContentFrame.UIInsurEcomMainPageDocument.UITxtPremiumEdit;
            BrowserWindow   uIInsurEcomSystemMaintWindow = map.UIInsurEcomSystemMaintWindow;
            HtmlEdit        uITxtRenewalDateEdit         = map.UIInsurEcomSystemMaintWindow.UIContentFrame.UIInsurEcomMainPageDocument.UITxtRenewalDateEdit;

            Mouse.Click(uICreateaMotorTestReneHyperlink, new Point(50, 22));

            uiInsurerIdComboBox.SelectedItem = insurer == "" ? this.map.MotoCreateSiteRenewalParams.UIInsurerIDComboBoxSelectedItem : insurer;

            uITxtPolicyNumberEdit.Text = policyNumber;

            uITxtPremiumEdit.Text = renewalPremium;

            uITxtAutoLapseDateEdit1.Text = uITxtRenewalDateEdit.GetProperty("Text").ToString();

            Mouse.Click(uICreateRecordButton);

            uIInsurEcomSystemMaintWindow.PerformDialogAction(BrowserDialogAction.Ok);
        }
예제 #13
0
        private HtmlHyperlink FindHyperlink()
        {
            HtmlHyperlink link = new HtmlHyperlink(bw);

            link.SearchProperties.Add(HtmlControl.PropertyNames.InnerText, "Add to cart", PropertyExpressionOperator.Contains);
            return(link);
        }
예제 #14
0
        //получаем ссылочку для смены аккаунта
        public HtmlHyperlink changeMail()
        {
            HtmlHyperlink link = new HtmlHyperlink(browser);

            link.SearchProperties["id"] = "click-to-change";
            return(link);
        }
예제 #15
0
        //public void test()
        //{
        //    WinWindow win = this.UIWindowsSecurityWindow2;

        //    if (!win.Exists)
        //        Assert.Fail("no window");
        //    Keyboard.SendKeys(win, "Bus Sys");
        //    Keyboard.SendKeys(win, "{Tab}");
        //    Keyboard.SendKeys(win, Playback.EncryptText("Tottenham1"));

        //    Keyboard.SendKeys(win, "Tottenham1");
        //    Playback.EncryptText("{Enter}");

        //}

        /// <summary>
        /// MotoCreateSiteRenewal - Use 'MotoCreateSiteRenewalParams' to pass parameters into this method.
        /// </summary>
        public void MotoCreateSiteRenewal()
        {
            #region Variable Declarations
            HtmlHyperlink   uICreateaMotorTestReneHyperlink = this.UIInsurEcomSystemMaintWindow.UILeftbarFrame.UIInsurEcomLeftbarDocument1.UIDivRenewalsPane.UICreateaMotorTestReneHyperlink;
            HtmlComboBox    uIInsurerIDComboBox             = this.UIInsurEcomSystemMaintWindow.UIContentFrame.UIInsurEcomMainPageDocument.UIInsurerIDComboBox;
            HtmlEdit        uITxtPolicyNumberEdit           = this.UIInsurEcomSystemMaintWindow.UIContentFrame.UIInsurEcomMainPageDocument.UITxtPolicyNumberEdit;
            HtmlEdit        uITxtAutoLapseDateEdit1         = this.UIInsurEcomSystemMaintWindow.UIContentFrame.UIInsurEcomMainPageDocument.UITxtAutoLapseDateEdit1;
            HtmlInputButton uICreateRecordButton            = this.UIInsurEcomSystemMaintWindow.UIContentFrame.UIInsurEcomMainPageDocument.UICreateRecordButton;
            BrowserWindow   uIInsurEcomSystemMaintWindow    = this.UIInsurEcomSystemMaintWindow;
            HtmlEdit        uITxtRenewalDateEdit            = this.UIInsurEcomSystemMaintWindow.UIContentFrame.UIInsurEcomMainPageDocument.UITxtRenewalDateEdit;
            #endregion

            // Click 'Create a Motor Test Renewal Invitation' link
            Mouse.Click(uICreateaMotorTestReneHyperlink, new Point(50, 22));

            // Select 'Highway Insurance' in 'InsurerID' combo box
            uIInsurerIDComboBox.SelectedItem = this.MotoCreateSiteRenewalParams.UIInsurerIDComboBoxSelectedItem;

            // Type '7071000841' in 'txtPolicyNumber' text box
            uITxtPolicyNumberEdit.Text = this.MotoCreateSiteRenewalParams.UITxtPolicyNumberEditText;

            // Type '12/11/2012' in 'txtAutoLapseDate' text box
            uITxtAutoLapseDateEdit1.Text = uITxtRenewalDateEdit.GetProperty("Text").ToString();

            // Click 'Create Record' button
            Mouse.Click(uICreateRecordButton, new Point(112, 11));

            // Click 'Ok' button in the browser dialog window
            uIInsurEcomSystemMaintWindow.PerformDialogAction(BrowserDialogAction.Ok);
        }
예제 #16
0
        public void Mouse_click_will_fail_because_hidden_link_is_matched_instead_of_visible_link()
        {
            // Playback.PlaybackSettings.SmartMatchOptions = SmartMatchOptions.None; // tried Sudhish Mathuria's suggestion

            var example2Path = Path.Combine(TestContext.TestDeploymentDir, "example2.htm");

            var window = BrowserWindow.Launch(example2Path);

            var document = new HtmlDocument(window);

            document.FilterProperties[HtmlDocument.PropertyNames.Title] = "2ad6de55-75f1-403f-8fcb-1d5defac9786";

            var visibleLink = new HtmlHyperlink(document);

            visibleLink.SearchProperties[HtmlHyperlink.PropertyNames.InnerText] = "Hello";

            // ONLY FIND VISIBLE CONTROLS !
            visibleLink.SearchConfigurations.Add(SearchConfiguration.VisibleOnly);

            var allMatches = visibleLink.FindMatchingControls();

            Assert.AreEqual(2, allMatches.Count, "Should be two matching.");

            visibleLink.Find(); // THIS SHOULD BE THE VISIBLE ONE

            Debug.WriteLine("BoundingRectangle: " + visibleLink.BoundingRectangle);
            Assert.IsTrue(visibleLink.BoundingRectangle.Width > 0, "Width should positive.");
            Assert.IsTrue(visibleLink.BoundingRectangle.Height > 0, "Height should positive.");

            Mouse.Click(visibleLink);
        }
예제 #17
0
 /// <summary>
 /// Searches for the hyperlink on the page
 /// </summary>
 private HtmlHyperlink FindHyperLinkOnPage(string innerLink)
 {
     var list = this.UIXeroDashboardInterneWindow.UIXeroDashboardDocument.UIXeronavPane;
     var hyperlink = new HtmlHyperlink(list);
     hyperlink.SearchProperties.Add(HtmlHyperlink.PropertyNames.InnerText, innerLink, PropertyExpressionOperator.Contains);
     return hyperlink;
 }
예제 #18
0
        private static HtmlHyperlink GetHtmlHyperlink(string uiTitle, string uiType)
        {
            dynamic htmlControl = new HtmlHyperlink(Browser.Locate(uiTitle, uiType));

            htmlControl.TechnologyName = TechnologyNameWeb;
            return(htmlControl);
        }
예제 #19
0
        /// <summary>
        /// addNewCar - Use 'addNewCarParams' to pass parameters into this method.
        /// </summary>
        public void addNewCar()
        {
            #region Variable Declarations
            HtmlHyperlink   uIPojazdyHyperlink   = this.UIIndexMyASPNETApplicaWindow.UIIndexMyASPNETApplicaDocument.UIBsexamplenavbarcollaPane.UIPojazdyHyperlink;
            HtmlHyperlink   uICreateNewHyperlink = this.UIIndexMyASPNETApplicaWindow.UIIndexMyASPNETApplicaDocument1.UICreateNewHyperlink;
            HtmlEdit        uIModelEdit          = this.UIIndexMyASPNETApplicaWindow.UICreateMyASPNETApplicDocument.UIModelEdit;
            HtmlEdit        uIRokprodukcjiEdit   = this.UIIndexMyASPNETApplicaWindow.UICreateMyASPNETApplicDocument.UIRokprodukcjiEdit;
            HtmlEdit        uIVinEdit            = this.UIIndexMyASPNETApplicaWindow.UICreateMyASPNETApplicDocument.UIVinEdit;
            HtmlInputButton uICreateButton       = this.UIIndexMyASPNETApplicaWindow.UICreateMyASPNETApplicDocument.UICreateButton;
            #endregion

            // Click 'Pojazdy' link
            Mouse.Click(uIPojazdyHyperlink, new Point(44, 32));

            // Click 'Create New' link
            Mouse.Click(uICreateNewHyperlink, new Point(56, 6));

            // Type 'Bmw' in 'Model' text box
            uIModelEdit.Text = this.addNewCarParams.UIModelEditText;

            // Type '{Tab}' in 'Model' text box
            Keyboard.SendKeys(uIModelEdit, this.addNewCarParams.UIModelEditSendKeys, ModifierKeys.None);

            // Type '2016' in 'Rok produkcji' text box
            uIRokprodukcjiEdit.Text = this.addNewCarParams.UIRokprodukcjiEditText;

            // Type 'znxmskndut' in 'Vin' text box
            uIVinEdit.Text = this.addNewCarParams.UIVinEditText;

            // Click 'Create' button
            Mouse.Click(uICreateButton, new Point(36, 15));
        }
예제 #20
0
        public void ClickLink(UITestControl parent, string innerText)
        {
            var link = new HtmlHyperlink(parent);

            link.SearchProperties.Add(HtmlHyperlink.PropertyNames.InnerText, innerText);
            Mouse.Click(link);
        }
예제 #21
0
 public EditStudentPage ClickEditStudent(string fullName)
 {
     HtmlHyperlink edit = new HtmlHyperlink(GetRow(fullName));
     edit.SearchProperties.Add(HtmlHyperlink.PropertyNames.InnerText, "Edit");
     Mouse.Click(edit);
     return new EditStudentPage();
 }
예제 #22
0
파일: WebLink.cs 프로젝트: Gnail-nehc/Brick
        public WebLink(List <UIProperty> controlProps)
        {
            BrowserWindow window = this.GetBrowser(controlProps);

            weblink = new HtmlHyperlink(window);
            controlProps.ForEach(property => weblink.SearchProperties[property.PropertyName] = property.PropertyValue);
        }
예제 #23
0
        private void MenuSelector(string option)
        {
            HtmlHyperlink link = new HtmlHyperlink(GetMenuContainer);

            link.SearchProperties.Add(HtmlHyperlink.PropertyNames.InnerText, option);
            Mouse.Click(link);
        }
예제 #24
0
        public void Click_OnHtmlHyperlink_InTableWithEmptyCell_Succeeds()
        {
            // Arrange
            using (var webPage = new TempWebPage(
                       @"<html>
    <head>
        <title>test</title>
    </head>
    <body>
        <table id=""tableId"">
            <tr id=""row"">
                <td></td>
                <td><a href=""#"">Details</a></td>
            </tr>
        </table>
    </body>
</html>"))
            {
                var browserWindow = BrowserWindow.Launch(webPage.FilePath);
                var table         = browserWindow.Find <HtmlTable>(By.Id("tableId"));

                HtmlCell      cell      = table.GetCell(0, 1);
                HtmlHyperlink hyperlink = cell.Find <HtmlHyperlink>();

                // Act
                hyperlink.Click();

                // TODO: Assert
                browserWindow.Close();
            }
        }
예제 #25
0
        public void ClickHeader(UITestControl parent, string value)
        {
            var link = new HtmlHyperlink(parent);

            link.SearchProperties.Add(HtmlHyperlink.PropertyNames.ValueAttribute, value);
            Mouse.Click(link);
        }
        /// <summary>
        /// Se prueba los componentes principales de la interfaz de creación de formulario
        /// </summary>
        public void PruebaInterfazBaseDeCrearFormulario()
        {
            #region Variable Declarations
            HtmlEdit        uICódigorequeridoEdit           = this.UILocalhost44334BingInWindow.UISistemadeMejoramientDocument1.UICódigorequeridoEdit;
            HtmlInputButton uIAgregarseccionesButton        = this.UILocalhost44334BingInWindow.UISistemadeMejoramientDocument1.UIAgregarseccionesButton;
            HtmlDiv         uIAúnnohaagregadosecciPane1     = this.UILocalhost44334BingInWindow.UISistemadeMejoramientDocument1.UIAúnnohaagregadosecciPane.UIAúnnohaagregadosecciPane1;
            HtmlDiv         uICambiossinguardarPane         = this.UILocalhost44334BingInWindow.UISistemadeMejoramientDocument1.UICambiossinguardarPane;
            HtmlHyperlink   uIVolveralbancodeformuHyperlink = this.UILocalhost44334BingInWindow.UISistemadeMejoramientDocument1.UIVolveralbancodeformuHyperlink;
            #endregion

            // Verify that the 'Id' property of 'Código requerido' text box equals 'textCode'
            Assert.AreEqual(this.PruebaInterfazBaseDeCrearFormularioExpectedValues.UICódigorequeridoEditId, uICódigorequeridoEdit.Id, "No se solicita el código del formulario");

            // Verify that the 'Id' property of 'Agregar secciones' button equals 'AgregarSeccion'
            Assert.AreEqual(this.PruebaInterfazBaseDeCrearFormularioExpectedValues.UIAgregarseccionesButtonId, uIAgregarseccionesButton.Id, "No aparece el botón de Agregar Secciones");

            // Verify that the 'InnerText' property of 'Aún no ha agregado secciones' pane equals 'Aún no ha agregado secciones'
            Assert.AreEqual(this.PruebaInterfazBaseDeCrearFormularioExpectedValues.UIAúnnohaagregadosecciPane1InnerText, uIAúnnohaagregadosecciPane1.InnerText, "No se notifica que no se han agregado secciones");

            // Verify that the 'InnerText' property of 'Cambios sin guardar' pane equals 'Cambios sin guardar '
            Assert.AreEqual(this.PruebaInterfazBaseDeCrearFormularioExpectedValues.UICambiossinguardarPaneInnerText, uICambiossinguardarPane.InnerText, "No se indica que hay cambios sin guardar antes de ingresar el código y el nombre " +
                            "del formulario.");

            // Verify that the 'InnerText' property of 'Volver al banco de formularios' link equals 'Volver al banco de formularios'
            Assert.AreEqual(this.PruebaInterfazBaseDeCrearFormularioExpectedValues.UIVolveralbancodeformuHyperlinkInnerText, uIVolveralbancodeformuHyperlink.InnerText, "No se muestra el botón de volver al banco de formularios");
        }
예제 #27
0
        public void HyperLinkIdClick(string id)
        {
            HtmlHyperlink Hyperlink = new HtmlHyperlink(Doc);

            Hyperlink.SearchProperties[HtmlHyperlink.PropertyNames.Id] = id;
            Mouse.Click(Hyperlink);
        }
예제 #28
0
        public void Launch_TempHtmlFile_CanFindHyperlinkByHref()
        {
            // Arrange
            using (var webPage = new TempWebPage(
                       @"<html>
    <head>
        <title>test</title>
    </head>
    <body>
        <div class=""login"" style=""border: none;"">
        <div class=""member_box"">
            <span>APPLY FOR MEMBERSHIP</span> <a href=""/registration""> </a>
        </div>
    </body>
</html>"))
            {
                // Act
                var browserWindow = BrowserWindow.Launch(webPage.FilePath);

                // Assert
                HtmlHyperlink SignUpHyperLink = browserWindow.Find <HtmlHyperlink>(By.SearchProperties("href~registration"));
                Assert.IsTrue(SignUpHyperLink.Exists, "SignUp not found");

                browserWindow.Close();
            }
        }
예제 #29
0
        /// <summary>
        /// AddToCart2
        /// </summary>
        public void AddToCart2()
        {
            #region Variable Declarations
            HtmlHyperlink uILightingHyperlink         = this.UIShoppingCartPartsUnlWindow.UIBrowseProductsPartsUDocument.UILightingHyperlink;
            HtmlImage     uIHalogenHeadlights2PaImage = this.UIShoppingCartPartsUnlWindow.UIBrowseProductsPartsUDocument1.UIHalogenHeadlights2PaImage;
            HtmlImage     uIImagesproduct_lightiImage = this.UIShoppingCartPartsUnlWindow.UIProductHalogenHeadliDocument.UIProductimagePane.UIImagesproduct_lightiImage;
            HtmlCell      uIWiringharnessincludeCell  = this.UIShoppingCartPartsUnlWindow.UIProductHalogenHeadliDocument.UIStoredetailsPane.UIItemTable.UIWiringharnessincludeCell;
            HtmlHyperlink uIAddtoCartHyperlink        = this.UIShoppingCartPartsUnlWindow.UIProductHalogenHeadliDocument.UIStoredetailsPane.UIAddtoCartHyperlink;
            #endregion

            // Click 'Lighting' link
            Mouse.Click(uILightingHyperlink, new Point(57, 17));

            // Click 'Halogen Headlights (2 Pack) zoom' image
            Mouse.Click(uIHalogenHeadlights2PaImage, new Point(316, 238));

            // Set flag to allow play back to continue if non-essential actions fail. (For example, if a mouse hover action fails.)
            Playback.PlaybackSettings.ContinueOnError = true;

            // Mouse hover '/Images/product_lighting_headlight.jpg' image at (1, 1)
            Mouse.Hover(uIImagesproduct_lightiImage, new Point(1, 1));

            // Mouse hover 'Wiring harness included' cell at (1, 1)
            Mouse.Hover(uIWiringharnessincludeCell, new Point(1, 1));

            // Reset flag to ensure that play back stops if there is an error.
            Playback.PlaybackSettings.ContinueOnError = false;

            // Click 'Add to Cart' link
            Mouse.Click(uIAddtoCartHyperlink, new Point(176, 46));
        }
예제 #30
0
        public void GetHtmlDiv_ByClass_Succeeds()
        {
            // Arrange
            using (var webPage = new TempWebPage(
                       @"<html>
    <head>
        <title>test</title>
    </head>
    <body>
        <div class=""button""><a href=""/main"">main text</a></div>
        <div class=""button""><a href=""/about"">about text</a></div>
    </body>
</html>"))
            {
                var browserWindow = BrowserWindow.Launch(webPage.FilePath);

                // Act
                HtmlDiv div = browserWindow.Find <HtmlDiv>(By.Class("button"));

                HtmlHyperlink about = browserWindow.Find <HtmlHyperlink>(By.SearchProperties("InnerText=about text;href~about"));
                HtmlDiv       div2  = about.Parent as HtmlDiv;

                // Assert
                Assert.IsTrue(div.Exists);
                Assert.AreEqual("main text", div.SourceControl.InnerText);

                Assert.IsTrue(about.Exists);

                Assert.IsTrue(div2.Exists);
                Assert.AreEqual("about text", div2.SourceControl.InnerText);

                browserWindow.Close();
            }
        }
예제 #31
0
        //ищем ссылочку
        public HtmlHyperlink findHyperLink()
        {
            HtmlHyperlink link = new HtmlHyperlink(browser);

            link.SearchProperties["class"] = "toolbar-link";
            return(link);
        }
예제 #32
0
        /// <summary>
        /// AddToCart
        /// </summary>
        public void AddToCart()
        {
            #region Variable Declarations
            HtmlHyperlink uIBrakesHyperlink = this.UIShoppingCartPartsUnlWindow.UIShoppingCartPartsUnlDocument.UIBrakesHyperlink;
            HtmlHyperlink uIDiskandPadCombo2599SHyperlink = this.UIShoppingCartPartsUnlWindow.UIBrowseProductsPartsUDocument.UIDiskandPadCombo2599SHyperlink;
            HtmlImage     uIImagesproduct_brakesImage     = this.UIShoppingCartPartsUnlWindow.UIProductDiskandPadComDocument.UIProductimagePane.UIImagesproduct_brakesImage;
            HtmlCell      uIDiameterCell       = this.UIShoppingCartPartsUnlWindow.UIProductDiskandPadComDocument.UIStoredetailsPane.UIItemTable.UIDiameterCell;
            HtmlHyperlink uIAddtoCartHyperlink = this.UIShoppingCartPartsUnlWindow.UIProductDiskandPadComDocument.UIStoredetailsPane.UIAddtoCartHyperlink;
            #endregion

            // Click 'Brakes' link
            Mouse.Click(uIBrakesHyperlink, new Point(56, 32));

            // Click 'Disk and Pad Combo 25,99 € Shop Now Disk and Pad ...' link
            Mouse.Click(uIDiskandPadCombo2599SHyperlink, new Point(299, 198));

            // Set flag to allow play back to continue if non-essential actions fail. (For example, if a mouse hover action fails.)
            Playback.PlaybackSettings.ContinueOnError = true;

            // Mouse hover '/Images/product_brakes_disk-pad-combo.jpg' image at (1, 1)
            Mouse.Hover(uIImagesproduct_brakesImage, new Point(1, 1));

            // Mouse hover 'Diameter' cell at (1, 1)
            Mouse.Hover(uIDiameterCell, new Point(1, 1));

            // Reset flag to ensure that play back stops if there is an error.
            Playback.PlaybackSettings.ContinueOnError = false;

            // Click 'Add to Cart' link
            Mouse.Click(uIAddtoCartHyperlink, new Point(229, 27));
        }
예제 #33
0
 public CreateInstructorsPage ClickCreateInstructors()
 {
     HtmlHyperlink link = new HtmlHyperlink(BrowserManager.Instance.Browser);
     link.SearchProperties.Add(HtmlHyperlink.PropertyNames.InnerText, "Create New");
     Mouse.Click(link);
     return new CreateInstructorsPage();
 }
예제 #34
0
 /// <summary>
 /// Find the hyperlink on the page
 /// </summary>
 private HtmlHyperlink FindHyperLinkOnPage(string innerLink)
 {
     var list = this.UILoginXeroAccountingSWindow.UILoginXeroAccountingSDocument;
     var hyperlink = new HtmlHyperlink(list);
     hyperlink.SearchProperties.Add(HtmlHyperlink.PropertyNames.InnerText, innerLink, PropertyExpressionOperator.Contains);
     return hyperlink;
 }
예제 #35
0
        /// <summary>
        /// ResetDatabase_Test
        /// </summary>
        public void ResetDatabase_Test()
        {
            #region Variable Declarations
            HtmlHyperlink uIAdministrationHyperlink = this.UIIndexWindowsInternetWindow.UIIndexDocument.UIMainMenuCustom.UIAdministrationHyperlink;
            HtmlHyperlink uIResetDatabaseHyperlink  = this.UIIndexWindowsInternetWindow.UIIndexDocument.UIMainMenuCustom.UIResetDatabaseHyperlink;
            HtmlDiv       uIItemPane1 = this.UIIndexWindowsInternetWindow.UIHttplocalhost1745DatDocument.UIItemPane1;
            #endregion

            // Click 'Administration' link
            Mouse.Click(uIAdministrationHyperlink, new Point(42, 21));

            // Click 'Reset Database' link
            Mouse.Click(uIResetDatabaseHyperlink, new Point(41, 13));

            // The following element is no longer available: IE web control; Process Id [6628], window handle [1770822]

            // Set flag to allow play back to continue if non-essential actions fail. (For example, if a mouse hover action fails.)
            Playback.PlaybackSettings.ContinueOnError = true;

            // Mouse hover  pane at (1, 1)
            Mouse.Hover(uIItemPane1, new Point(1, 1));

            // The following element is no longer available: IE web control; Process Id [6628], window handle [1770822]

            // Reset flag to ensure that play back stops if there is an error.
            Playback.PlaybackSettings.ContinueOnError = false;
        }
 public HtmlHyperlink GetHyperLinkWithInnerText(string innerText)
 {
     var mUILOLHyperlink = new HtmlHyperlink();
     #region Search Criteria
     mUILOLHyperlink.SearchProperties[HtmlHyperlink.PropertyNames.InnerText] = innerText;
     #endregion
     return mUILOLHyperlink;
 }
예제 #37
0
 public DeleteStudentPage DeleteStudent(string fullName)
 {
     /*TODO*/
     HtmlHyperlink del = new HtmlHyperlink(GetRow(fullName));
     del.SearchProperties.Add(HtmlHyperlink.PropertyNames.InnerText, "Delete");
     Mouse.Click(del);
     return new DeleteStudentPage();
 }
예제 #38
0
        public ShoppingBasketPage AddProductToCart()
        {
            HtmlHyperlink ProductLink = new HtmlHyperlink(_bw);
            ProductLink.SearchProperties.Add(HtmlControl.PropertyNames.InnerText, "Add to Cart", PropertyExpressionOperator.Contains);
            Mouse.Click(ProductLink);

            return new ShoppingBasketPage(_bw);
        }
예제 #39
0
        public CreateInstructorsPage ClickCreateInstructors()
        {
            HtmlHyperlink link = new HtmlHyperlink(BrowserManager.Instance.Browser);

            link.SearchProperties.Add(HtmlHyperlink.PropertyNames.InnerText, "Create New");
            Mouse.Click(link);
            return(new CreateInstructorsPage());
        }
예제 #40
0
        public static bool HoverStateMenu(String strStateName)
        {
            HtmlHyperlink siteLink = new HtmlHyperlink(HomePage.BrowserInstance);
            siteLink.SearchProperties[HtmlHyperlink.PropertyNames.InnerText] = strStateName;
            siteLink.SearchProperties[HtmlHyperlink.PropertyNames.Href] = GetStateHyperLink(strStateName);

            Mouse.Hover(siteLink);

            return true;
        }
        public static bool GoTo()
        {
            HtmlHyperlink siteLink = new HtmlHyperlink(HomePage.BrowserInstance);
            siteLink.SearchProperties[HtmlHyperlink.PropertyNames.InnerText] = "Fernbrooke Ridge";
            siteLink.SearchProperties[HtmlHyperlink.PropertyNames.Href] = Constants.FernbrookeHyperlink;

            Mouse.Click(siteLink);

            return true;
        }
예제 #42
0
파일: HomePage.cs 프로젝트: XpiritBV/PU
        public CategoryPage SelectCategory(string categoryName)
        {
            HtmlDiv categoryDiv = new HtmlDiv(_bw);
            categoryDiv.SearchProperties.Add(HtmlControl.PropertyNames.Class, "hidden-xs", PropertyExpressionOperator.Contains);

            HtmlHyperlink lightingCategoryLink = new HtmlHyperlink(categoryDiv);
            lightingCategoryLink.SearchProperties.Add(HtmlControl.PropertyNames.InnerText, categoryName, PropertyExpressionOperator.Contains);

            Mouse.Click(lightingCategoryLink);

            return new CategoryPage(_bw);
        }
예제 #43
0
파일: CategoryPage.cs 프로젝트: XpiritBV/PU
        public ProductDetailsPage SelectProduct(string productName)
        {
            HtmlDiv LightingList = new HtmlDiv(_bw);
            LightingList.SearchProperties.Add(HtmlControl.PropertyNames.Class, "list-item-part", PropertyExpressionOperator.Contains);

            HtmlHyperlink lightingProduct = new HtmlHyperlink(LightingList);
            lightingProduct.SearchProperties.Add(HtmlControl.PropertyNames.Title, productName, PropertyExpressionOperator.Contains);

            Mouse.Click(lightingProduct);

            return new ProductDetailsPage(_bw);
        }
예제 #44
0
파일: UIMap.cs 프로젝트: choogajster/auto
        public static void ClickLinkByName(string name)
        {
            #region Variable Declarations

            HtmlHyperlink lnk = new HtmlHyperlink(browserWindow);
            lnk.SearchProperties.Add(HtmlCustom.PropertyNames.InnerText, name,
                PropertyExpressionOperator.EqualTo);

            lnk.SearchProperties.Add(HtmlCustom.PropertyNames.InnerText, name, PropertyExpressionOperator.Contains);
            lnk.SearchProperties.Add(HtmlCustom.PropertyNames.FriendlyName, name, PropertyExpressionOperator.Contains);
            #endregion

            lnk.WaitForControlExist();
            Mouse.Click(lnk);
        }
예제 #45
0
 public static void ClickHyperLink()
 {
     var hyperLink = new HtmlHyperlink(browserWindow);
     try
     {
         hyperLink.SearchProperties.Add(CSVReader.ControlType + ".PropertyNames." + CSVReader.LocatorType, CSVReader.LocatorValue);
         hyperLink.WaitForControlEnabled();
         hyperLink.WaitForControlReady();
     }
     catch (Exception)
     {
         Assert.Fail("Failed to find " + CSVReader.ControlType + " Element - Element not Found");
     }
     Mouse.Click(hyperLink);
 }
        public static bool Open()
        {
            HomePage.BrowserInstance.SearchProperties[UITestControl.PropertyNames.Name] = "Fernbrooke Ridge - A Lendlease Community";

            HtmlDocument doc = new HtmlDocument(HomePage.BrowserInstance);
            doc.SearchProperties[HtmlDocument.PropertyNames.Title] = "Fernbrooke Ridge - A Lendlease Community";
            doc.SearchProperties[HtmlDocument.PropertyNames.PageUrl] = Constants.FernbrookeHyperlink;

            HtmlDiv div = new HtmlDiv(doc);
            div.SearchProperties[HtmlDiv.PropertyNames.Id] = "menu-container";
            div.SearchProperties.Add(HtmlDiv.PropertyNames.InnerText, "Fernbrooke Ridge", PropertyExpressionOperator.Contains);
            div.SearchProperties[HtmlDiv.PropertyNames.Class] = "collapse navbar-collapse";

            HtmlHyperlink link = new HtmlHyperlink(div);
            link.SearchProperties.Add(HtmlDiv.PropertyNames.InnerText, "Living in Fernbrooke Ridge", PropertyExpressionOperator.Contains);
            link.SearchProperties[HtmlHyperlink.PropertyNames.Href] = "http://communities.lendlease.com/fernbrooke-ridge/living-in-fernbrooke-ridge";

            return link.Exists;
        }
예제 #47
0
        public void BuyOneProductCodedUI()
        {
            var bw = BrowserWindow.Launch("http://localhost:5001");
            HtmlDiv categoryDiv = new HtmlDiv(bw);
            categoryDiv.SearchProperties.Add(HtmlControl.PropertyNames.Class, "hidden-xs", PropertyExpressionOperator.Contains);

            HtmlHyperlink lightingCategoryLink = new HtmlHyperlink(categoryDiv);
            lightingCategoryLink.SearchProperties.Add(HtmlControl.PropertyNames.InnerText, "Lighting", PropertyExpressionOperator.Contains);

            Mouse.Click(lightingCategoryLink);
            HtmlDiv Container = new HtmlDiv(bw);
            Container.SearchProperties.Add(HtmlControl.PropertyNames.Class, "container", PropertyExpressionOperator.Contains);

            HtmlHyperlink lightingProduct = new HtmlHyperlink(bw);
            lightingProduct.SearchProperties.Add(HtmlControl.PropertyNames.Title, "Halogen Headlights", PropertyExpressionOperator.Contains);

            Mouse.Click(lightingProduct);

            HtmlHyperlink ProductLink = new HtmlHyperlink(bw);
            ProductLink.SearchProperties.Add(HtmlControl.PropertyNames.InnerText, "Add to Cart", PropertyExpressionOperator.Contains);

            Assert.IsTrue(ProductLink.TryFind());
        }
예제 #48
0
        public void HyperlinkTextClick(string innertext)
        {
            HtmlHyperlink a = new HtmlHyperlink(Doc);
            a.SearchProperties[HtmlHyperlink.PropertyNames.InnerText] = innertext;
            Mouse.Click(a);

        }
예제 #49
0
 //ищем ссылочку
 public HtmlHyperlink findHyperLink() {
     HtmlHyperlink link = new HtmlHyperlink(browser);
     link.SearchProperties["class"] = "toolbar-link";
     return link; 
 }
 private void ClickTryAgainHyperLink(BrowserWindow browser)
 {
     var hyperLink = new HtmlHyperlink(browser);
     hyperLink.SearchProperties.Add(HtmlHyperlink.PropertyNames.InnerText, "Try Again");
     Mouse.Click(hyperLink);
 }
예제 #51
0
 private void MenuSelector(string option)
 {
     HtmlHyperlink link = new HtmlHyperlink(GetMenuContainer);
     link.SearchProperties.Add(HtmlHyperlink.PropertyNames.InnerText, option);
     Mouse.Click(link);
 }
예제 #52
0
 //получаем ссылочку для смены аккаунта
 public HtmlHyperlink changeMail()
 {
     HtmlHyperlink link = new HtmlHyperlink(browser);
     link.SearchProperties["id"] = "click-to-change";
     return link;
 }
예제 #53
0
파일: WebLink.cs 프로젝트: Gnail-nehc/Brick
 public WebLink(List<UIProperty> controlProps)
 {
     BrowserWindow window = this.GetBrowser(controlProps);
     weblink = new HtmlHyperlink(window);
     controlProps.ForEach(property => weblink.SearchProperties[property.PropertyName] = property.PropertyValue);
 }
예제 #54
0
 public void HyperLinkIdClick(string id)
 {
     HtmlHyperlink Hyperlink = new HtmlHyperlink(Doc);
     Hyperlink.SearchProperties[HtmlHyperlink.PropertyNames.Id] = id;
     Mouse.Click(Hyperlink);
 }
        /// <summary>
        /// Inserts a new hyperlink.
        /// </summary>
        /// <param name="text">Text to display. This text will only be set in case there is no selection in the editor.</param>
        /// <param name="link">Target of the hyperlink. Can either be an www-link or the v-modell id of a model element.</param>
        public void InsertHyperlink(string text, string link)
        {
            //if (updateSelectionPropertiesPending)
            //    return;

            string targetText = text;
            if (!this.Selection.IsEmpty)
            {
                // see first if there is a hyperlink inside the selection
                /*
                TextRange range = new TextRange(this.Selection.Start, this.Selection.End);
                
                foreach (Inline inline in this.Selection.Start.Paragraph.Inlines)
                {
                    if (inline is Hyperlink)
                    {
                        MessageBox.Show("Another hyperlink already in selection! Can not include a hyperlink in an another hyperlink.");
                        return;
                    }
                }*/
            }

            HtmlHyperlink hyperlink;
            if (!this.Selection.IsEmpty)
            {
                hyperlink = new HtmlHyperlink(this.Selection.Start, this.Selection.End);
            }
            else
            {
                hyperlink = new HtmlHyperlink(this.Selection.Start, this.Selection.End);

                hyperlink.Inlines.Add(new Run(text));
                //if (this.Selection.Start.Paragraph == null)
                //{
                //    Paragraph p = new Paragraph();
                //    this.Document.Blocks.Add(p);

                //    p.Inlines.Add(hyperlink);
                //}
                //else
                //    this.Selection.Start.Paragraph.Inlines.Add(hyperlink);
                this.Focus();
            }

            hyperlink.TargetName = link;
        }
        /// <summary>
        /// Execute the Html navigation command.
        /// </summary>
        public void NavigateToHtmlHyperlink(HtmlHyperlink hyperlink)
        {
            if (hyperlink.TargetName.Length == 0)
                return;

            bool bFoundTarget = false;
            if (hyperlink.TargetName[0] == '#')
            {
                string href = hyperlink.TargetName.Substring(1, hyperlink.TargetName.Length - 1);
                if (KeyGenerator.Instance.CanConvertVModellIDToGuid(href))
                {
                    Guid id = KeyGenerator.Instance.ConvertVModellIDToGuid(href);
                    ModelElement modelElement = this.Store.ElementDirectory.FindElement(id);
                    if (modelElement != null)
                    {
                        bFoundTarget = true;

                        SelectedItemsCollection col = new SelectedItemsCollection();
                        col.Add(modelElement);
                        EventManager.GetEvent<SelectionChangedEvent>().Publish(new SelectionChangedEventArgs(this, col));

                    }
                }
            }

            if (!bFoundTarget)
                System.Windows.MessageBox.Show(hyperlink.TargetName);
        }
        /// <summary>
        /// Modify the given hyperlink.
        /// </summary>
        public void ModifyHtmlHyperlink(HtmlHyperlink hyperlink)
        {
            using (HtmlSelectHyperlinkViewModel vm = new HtmlSelectHyperlinkViewModel(this.ViewModelStore))
            {
            vm.Title = "Edit a hyperlink";

            if (hyperlink.TargetName.Length > 0)
            {
                bool bFoundTarget = false;
                if (hyperlink.TargetName[0] == '#')
                {
                    string href = hyperlink.TargetName.Substring(1, hyperlink.TargetName.Length - 1);
                    if (KeyGenerator.Instance.CanConvertVModellIDToGuid(href))
                    {
                        Guid id = KeyGenerator.Instance.ConvertVModellIDToGuid(href);
                        ModelElement modelElement = this.Store.ElementDirectory.FindElement(id);
                        if (modelElement != null)
                        {
                            bFoundTarget = true;
                            vm.SetSelectedElement(modelElement);
                        }
                    }
                }

                if (!bFoundTarget)
                {
                    if (!String.IsNullOrEmpty(hyperlink.TargetName))
                        vm.SetSelectedElement(hyperlink.TargetName);
                }
            }

            bool? result = this.GlobalServiceProvider.Resolve<IUIVisualizerService>().ShowDialog("SelectHyperlinkPopup", vm);
            if (result == true)
            {
                if (vm.SelectedElement is string)
                {
                    hyperlink.TargetName = vm.SelectedElement as string;
                }
                else if (vm.SelectedElement is ModelElement)
                {
                    hyperlink.TargetName = "#" + KeyGenerator.Instance.ConvertGuidToVModellID(
                        (vm.SelectedElement as ModelElement).Id);
                }
            }
            }
            GC.Collect();
        }
예제 #58
0
        public static UITestControlCollection GetAllHtmlLinkControls()
        {
            var link = new HtmlHyperlink(browserWindow);
            link.SearchProperties.Add(CSVReader.ControlType + ".PropertyNames." + CSVReader.LocatorType, CSVReader.LocatorValue);

            var controlCollection = link.FindMatchingControls();
            return controlCollection;
        }
        /*
        /// <summary>
        /// Convert an flow document inlines into their (combined!) html representation.
        /// </summary>
        /// <param name="inlines">Flow document inlines collection.</param>
        /// <param name="htmlWriter">XmlTextWriter producing resulting html.</param>
        /// <param name="conversionResult">Conversion result to store error and warning messages. Can be null.</param>
        /// <remarks>
        /// Supported: Hyperlink, Bold, Underline, Italic as well as Run and InlineUIContainer for Image.
        /// </remarks>
        private static void AddInlines(InlineCollection inlines, XmlTextWriter htmlWriter, ConversionResult conversionResult)
        {
            bool bBold = false;
            bool bItalic = false;
            bool bUnderlined = false;

            for (int i = 0; i < inlines.Count; ++i)
            {
                Inline inline = inlines.ElementAt(i);
                if (inline is Run || inline is Span)
                {
                    bool bAddBold = false;
                    bool bAddItalic = false;
                    bool bAddUnderlined = false;

                    // Bold
                    if (bBold && inline.FontWeight != System.Windows.FontWeights.Bold)
                    {
                        // close last element tag
                        htmlWriter.WriteEndElement();
                        bBold = false;
                    }
                    else if (!bBold && inline.FontWeight == System.Windows.FontWeights.Bold)
                        bAddBold = true;

                    // Italic
                    if (bItalic && inline.FontStyle != System.Windows.FontStyles.Italic)
                    {
                        // close last element tag
                        htmlWriter.WriteEndElement();
                        bItalic = false;
                    }
                    else if (!bItalic && inline.FontStyle == System.Windows.FontStyles.Italic)
                        bAddItalic = true;

                    // Underline
                    if (bUnderlined && !inline.TextDecorations.Contains(System.Windows.TextDecorations.Underline[0]))
                    {
                        // close last element tag
                        htmlWriter.WriteEndElement();
                        bUnderlined = false;
                    }
                    else if (!bUnderlined && inline.TextDecorations.Contains(System.Windows.TextDecorations.Underline[0]))
                        bAddUnderlined = true;

                    // see what needs to be added.. if multiple elements need to be added, than we have to iterate through
                    // siblings to see what tag to set first (depending on what to close first).
                    if( bAddUnderlined || bAddBold || bAddItalic )
                    {
                        if (bAddBold && bAddItalic || bAddBold && bAddUnderlined || bAddItalic && bAddUnderlined)
                        {
                            // see what has to be added first
                            int iBold = 0;
                            int iItalic = 0;
                            int iUnderlined = 0;

                            for (int y = i+1; y < inlines.Count; ++y)
                            {
                                Inline inlineY = inlines.ElementAt(y);
                                if (inlineY.FontStyle == System.Windows.FontStyles.Italic)
                                    iItalic++;
                                if (inlineY.FontWeight == System.Windows.FontWeights.Bold)
                                    iBold++;
                                if (inlineY.TextDecorations.Contains(System.Windows.TextDecorations.Underline[0]))
                                    iUnderlined++;
                            }

                            List<InlineStyles> addOrder = new List<InlineStyles>();
                            addOrder.Add(InlineStyles.Bold);
                            if (iItalic > iBold)
                                addOrder.Insert(0, InlineStyles.Italic);
                            else
                                addOrder.Add(InlineStyles.Italic);

                            for (int z = 0; z < 2; ++z)
                            {
                                if (addOrder[z] == InlineStyles.Bold && iUnderlined > iBold)
                                {
                                    addOrder.Insert(z, InlineStyles.Underlined);
                                    break;
                                }
                                else if (addOrder[z] == InlineStyles.Italic && iUnderlined > iItalic)
                                {
                                    addOrder.Insert(z, InlineStyles.Underlined);
                                    break;
                                }
                                else if (z == 1)
                                    addOrder.Add(InlineStyles.Underlined);
                            }

                            // add tags
                            for (int z = 0; z < 3; ++z)
                            {
                                if (addOrder[z] == InlineStyles.Bold && bAddBold)
                                {
                                    htmlWriter.WriteStartElement("b");
                                    bBold = true;
                                }
                                else if (addOrder[z] == InlineStyles.Italic && bAddItalic)
                                {
                                    htmlWriter.WriteStartElement("i");
                                    bItalic = true;
                                }
                                else if (addOrder[z] == InlineStyles.Underlined && bAddUnderlined)
                                {
                                    htmlWriter.WriteStartElement("u");
                                    bUnderlined = true;
                                }
                            }
                        }
                        else
                        {
                            // just add the tag of the needed style
                            if (bAddBold)
                            {
                                htmlWriter.WriteStartElement("b");
                                bBold = true;
                            }
                            else if (bAddItalic)
                            {
                                htmlWriter.WriteStartElement("i");
                                bItalic = true;
                            }
                            else if (bAddUnderlined)
                            {
                                htmlWriter.WriteStartElement("u");
                                bUnderlined = true;
                            }
                        }
                    }

                    // continue with text or inlines
                    if (inline is Run)
                    {
                        htmlWriter.WriteString((inline as Run).Text);
                    }
                    else
                    {
                        Span span = inline as Span;
                        AddInlines(span.Inlines, htmlWriter, conversionResult);
                    }
                }
                else if (inline is InlineUIContainer)
                {
                    InlineUIContainer container = inline as InlineUIContainer;
                    if (container.Child is HtmlImage)
                    {
                        // Add image
                        // TODO...
                    }
                    else
                    {
                        // not supported
                        if (conversionResult != null)
                        {
                            conversionResult.AddMessage(new ConversionMessage(ConversionMessageKind.Warning,
                                "AddInline: Unknown inline ui container child: " + container.Child.ToString()));
                        }
                    }
                }
                else if (inline is HtmlHyperlink)
                {
                    // Add hyperlink
                    AddHyperlink(inline as HtmlHyperlink, htmlWriter, conversionResult);
                }
                else
                {
                    // not supported
                    if (conversionResult != null)
                    {
                        conversionResult.AddMessage(new ConversionMessage(ConversionMessageKind.Warning,
                            "AddInline: Unknown inline element: " + inline.ToString()));
                    }

                }
            }

            if (bBold)
                htmlWriter.WriteEndElement();

            if (bItalic)
                htmlWriter.WriteEndElement();

            if (bUnderlined)
                htmlWriter.WriteEndElement();
        }

        */

        /// <summary>
        /// Convert an flow document hyperlink into its html representation.
        /// </summary>
        /// <param name="hyperlink">Flow document hyperlink.</param>
        /// <param name="htmlWriter">XmlTextWriter producing resulting html.</param>
        /// <param name="conversionResult">Conversion result to store error and warning messages. Can be null.</param>
        /// <param name="inheritedStyle">Inherited inline styles.</param>
        private static void AddHyperlink(HtmlHyperlink hyperlink, XmlTextWriter htmlWriter, ValidationResult conversionResult, List<InlineStyles> inheritedStyle)
        {
            htmlWriter.WriteStartElement("a");

            //if (Tum.VModellXT.Keys.KeyGenerator.Instance.CanConvertVModellIDToGuid(hyperlink.TargetName))
            //{
            //   htmlWriter.WriteAttributeString("href", "#" + hyperlink.TargetName);
            // }
            //else
            htmlWriter.WriteAttributeString("href", hyperlink.TargetName);

            // process inlines
            AddInlines(hyperlink.Inlines, htmlWriter, conversionResult, inheritedStyle);

            htmlWriter.WriteEndElement();
        }
예제 #60
0
 // получение ссылки создания нового пользователя
 public HtmlHyperlink CreateOneHere()
 {
     HtmlHyperlink link = new HtmlHyperlink(browser);
     link.SearchProperties["class"] = "signupLink";
     return link;
 }