Пример #1
0
        public static void SafeSelectWebelement(string ElementName, string Action)
        {
            try
            {
                string ElementLocator = AllPages.getElementLocator(ElementName);
                WaitToAppear(ElementLocator);
                IWebElement WebElement = WebDriver.FindElement(By.CssSelector(ElementLocator));

                if (Action == "click")
                {
                    WebElement.Click();
                }
                else
                {
                    if (Action == "safeclick")
                    {
                        WebElement.Click();
                    }
                    if (Action == "enter")
                    {
                        WebElement.SendKeys(Keys.Enter);
                    }
                    if (Action == "return")
                    {
                        WebElement.SendKeys(Keys.Return);
                    }
                }
                Console.WriteLine("Selected the element with locator" + ElementLocator + " with " + Action);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }
Пример #2
0
        public static string ReadFromWebelement(string ElementName, string Attribute)
        {
            string Text = "";

            try
            {
                string ElementLocator = AllPages.getElementLocator(ElementName);
                WaitToAppear(ElementLocator);
                IWebElement WebElement = WebDriver.FindElement(By.CssSelector(ElementLocator));

                if (Attribute == "text")
                {
                    Text = WebElement.Text;
                }
                if (Attribute == "attributetext")
                {
                    Text = WebElement.GetAttribute("text");
                }
                if (Attribute == "attributevalue")
                {
                    Text = WebElement.GetAttribute("value");
                }
                Console.WriteLine(Text + " read from element with locator " + ElementLocator);

                return(Text);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                return(Text);
            }
        }
Пример #3
0
        public void BeforeScenario()
        {
            WebDriver.ConfigureDriver();
            var webdriver = WebDriver.Driver;

            webdriver.Navigate().GoToUrl("about:blank");
            var testdriver = new SeleniumDriver();

            AllPages.Loadpages(testdriver);
        }
Пример #4
0
 private static void DiscoverPages <IPageType>(Assembly asm = null)
 {
     try
     {
         if (asm == null)
         {
             asm = Assembly.GetEntryAssembly();
         }
         foreach (var t in asm.GetTypes())
         {
             if (!t.IsAbstract)
             {
                 var iface = t.GetInterfaces().FirstOrDefault(i => i == typeof(IPageType));// i.FullName == "W.WPF.Framework.IPage");
                 if (iface != null)
                 {
                     //var page = Activator.CreateInstance(t) as IPage;
                     var pw = new PageWrapper()
                     {
                         //Name = t.Name,
                         Type = t,
                         //PageXaml = t.FullName,
                         //Page = new Lazy<IPage>(() => Activator.CreateInstance(t) as IPage)
                         FrameworkElement = (FrameworkElement)Activator.CreateInstance(t)
                     };
                     AllPages.Add(pw);
                 }
             }
         }
         foreach (AssemblyName assemblyName in asm.GetReferencedAssemblies())
         {
             try
             {
                 if (assemblyName.CodeBase?.Trim('/', '\\') == AppDomain.CurrentDomain.BaseDirectory.Trim('/', '\\'))
                 //if (!assemblyName.Name.StartsWith("System") && !(assemblyName.Name.StartsWith("mscorlib")))
                 {
                     Log.i("Loading {0}", assemblyName);
                     var assembly = Assembly.Load(assemblyName.Name);
                     if (assembly != null)
                     {
                         DiscoverPages <IPageType>(assembly);
                     }
                 }
             }
             catch (Exception e)
             {
                 Log.e(e);
             }
         }
     }
     catch (Exception e)
     {
         Log.e(e);
     }
 }
Пример #5
0
        //public static string LinesToString( ICollection<string> lines )
        //{
        //	var b = new StringBuilder();
        //	bool first = true;
        //	foreach( var line in lines )
        //	{
        //		if( !first )
        //			b.Append( "\r\n" );
        //		b.Append( line );
        //		first = false;
        //	}
        //	return b.ToString();
        //}

        static DebugInfoPage()
        {
            AllPages.Add(new DebugInfoPage_Memory());
            AllPages.Add(new DebugInfoPage_RenderResources());
            AllPages.Add(new DebugInfoPage_RenderStatistics());
            AllPages.Add(new DebugInfoPage_Sound());
            //AllPages.Add( new DebugInfoPage_Scene() );

            //ломает звук. странно
            //AllPages.Add( new DebugInfoPage_Assemblies() );
            //AllPages.Add( new DebugInfoPage_DLLs() );
        }
Пример #6
0
 public static void UploadFile(string FilePath, string ElementName)
 {
     try
     {
         string ElementLocator = AllPages.getElementLocator(ElementName);
         WebDriver.FindElement(By.CssSelector(ElementLocator)).SendKeys(FilePath);
         Console.WriteLine("Uploaded the file with path " + FilePath + " to element with locator " + ElementLocator);
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.ToString());
     }
 }
Пример #7
0
 public static void SelectFromDropDownByClick(string DropDownName, string OptionName)
 {
     try
     {
         string DropDownLocator = AllPages.getElementLocator(DropDownName);
         string OptionLocator   = AllPages.getElementLocator(OptionName);
         SelectWebElement(DropDownLocator);
         SelectWebElement(OptionLocator);
         Console.WriteLine("Selected the element with locator " + OptionLocator + " from dropdown with locator " + DropDownLocator);
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.ToString());
     }
 }
Пример #8
0
        public static void EnterInToWebelement(string Entry, string ElementName)
        {
            try
            {
                string ElementLocator = AllPages.getElementLocator(ElementName);
                WaitToAppear(ElementLocator);
                IWebElement WebElement = WebDriver.FindElement(By.CssSelector(ElementLocator));

                WebElement.SendKeys(Entry);
                Console.WriteLine(Entry + " entered into the element with locator " + ElementLocator);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }
Пример #9
0
        private IPage FindOrCreatePage(ITdiTab tab)
        {
            if (tab == null)
            {
                return(null);
            }

            ITdiPage page = AllPages.OfType <ITdiPage>().FirstOrDefault(x => x.TdiTab == tab);

            if (page == null)
            {
                page = new TdiTabPage(tab, null);
                pages.Add(page);
            }

            return((IPage)page);
        }
Пример #10
0
        public static void SelectFromDropDownBySelect(string OptionText, string DropDownName)
        {
            try
            {
                string        DropDownLocator = AllPages.getElementLocator(DropDownName);
                IWebElement   DropDown        = WebDriver.FindElement(By.CssSelector(DropDownLocator));
                SelectElement Select          = new SelectElement(DropDown);

                Select.SelectByText(OptionText);

                Console.WriteLine("Selected the element with text " + OptionText + " from dropdown with locator " + DropDownLocator);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }
Пример #11
0
 public static void SelectCheckBox(string CheckBoxName)
 {
     try
     {
         string CheckBoxLocator = AllPages.getElementLocator(CheckBoxName);
         SelectWebElement(CheckBoxLocator);
         IWebElement RadioButton = WebDriver.FindElement(By.CssSelector(CheckBoxLocator));
         if (RadioButton.Selected)
         {
             Console.WriteLine("Selected");
         }
         else
         {
             Console.WriteLine("UnSelected");
         }
         Console.WriteLine("Selected the CheckBox with locator " + CheckBoxLocator);
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.ToString());
     }
 }
Пример #12
0
 public static void SelectRadioButton(string RadioButtonName)
 {
     try
     {
         string RadioButtonLocator = AllPages.getElementLocator(RadioButtonName);
         SelectWebElement(RadioButtonLocator);
         IWebElement RadioButton = WebDriver.FindElement(By.CssSelector(RadioButtonLocator));
         if (RadioButton.GetAttribute("checked") == "checked")
         {
             Console.WriteLine("Checked");
         }
         else
         {
             Console.WriteLine("UnChecked");
         }
         Console.WriteLine("Selected the RadioButton with locator " + RadioButtonLocator);
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.ToString());
     }
 }
Пример #13
0
        public static void SelectFromDropDownByText(string DropDownName, string OptionsLocator, string OptionText)
        {
            try
            {
                string DropDownLocator = AllPages.getElementLocator(DropDownName);
                SelectWebElement(DropDownLocator);

                IList <IWebElement> Options = WebDriver.FindElements(By.CssSelector(OptionsLocator));

                foreach (var Option in Options)
                {
                    if (Option.Text == OptionText)
                    {
                        Option.Click();
                    }
                }

                Console.WriteLine("Selected the element with text " + OptionText + " from dropdown with locator " + DropDownLocator);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }
Пример #14
0
 public Pages()
 {
     _all_pages = AllPages.GroupBy(x => x.Group).ToDictionary(x => x.Key.ToString(), y => y.ToList());
 }
Пример #15
0
 public IPage FindPage(Gdk.Window window)
 {
     return(AllPages.OfType <IGtkWindowPage>().FirstOrDefault(x => x.GtkDialog.GdkWindow == window));
 }
Пример #16
0
 private IPage FindPage(ITdiTab tab)
 {
     return(AllPages.OfType <ITdiPage>().FirstOrDefault(x => x.TdiTab == tab));
 }
Пример #17
0
 public void BeforeScenario()
 {
     driverFacade = new DriverFacade();
     pages        = new AllPages(driverFacade);
 }
Пример #18
0
 public CarsTest(ITestOutputHelper output)
 {
     this.output = output;
     driver      = LoadDriver();
     Pages       = new AllPages(driver);
 }
Пример #19
0
 public IPage FindPage(DialogViewModelBase viewModel)
 {
     return(AllPages.FirstOrDefault(x => x.ViewModel == viewModel));
 }
Пример #20
0
 public void Setup()
 {
     Driver.Init();
     AllPages.Init();
     Driver.GoTo("https://localhost:5001/");
 }
Пример #21
0
 public static void Init()
 {
     AllPages.Init();
 }
Пример #22
0
 public static void Dispose()
 {
     AllPages.Dispose();
 }