public void BuildDeployAnTest()
        {
            var processStartInfo = new ProcessStartInfo{
                FileName = @"C:\Windows\Microsoft.NET\Framework\v3.5\MSBuild.exe",
                Arguments = @"/nologo /clp:ErrorsOnly WebApplication\WebApplication.csproj",
                WorkingDirectory = AppDomain.CurrentDomain.BaseDirectory,
                RedirectStandardInput = true,
                RedirectStandardOutput = true,
                RedirectStandardError = true,
                UseShellExecute = false,
                CreateNoWindow = true
            };
            Process buildProcess = Process.Start(processStartInfo);
            buildProcess.WaitForExit();
            Assert.AreEqual(0, buildProcess.ExitCode, "Compilation error: " + buildProcess.StandardOutput.ReadToEnd());

            Process webServerProcess = Process.Start(new ProcessStartInfo{
                FileName = @"C:\Program Files\Common Files\microsoft shared\DevServer\9.0\WebDev.WebServer.EXE",
                Arguments = "/port:12345 /path:\"" + Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "WebApplication") + "\"",
                RedirectStandardInput = true,
                RedirectStandardOutput = true,
                RedirectStandardError = true,
                UseShellExecute = false,
                CreateNoWindow = true
            });

            Process seleniumRcProcess = Process.Start(new ProcessStartInfo{
                FileName = "java.exe",
                Arguments = @"-jar selenium-server\selenium-server.jar",
                WorkingDirectory = AppDomain.CurrentDomain.BaseDirectory,
                RedirectStandardInput = true,
                RedirectStandardOutput = true,
                RedirectStandardError = true,
                UseShellExecute = false,
                CreateNoWindow = true,
            });

            ISelenium selenium = new DefaultSelenium("localhost", 4444, "*chrome", "http://localhost:12345");
            selenium.Start();

            selenium.Open("/");
            selenium.Type("inputTextBox", "Test input");
            selenium.Click("actionButton");
            selenium.WaitForPageToLoad("30000");
            Assert.IsTrue(selenium.IsTextPresent("Test input"));

            try
            {
                selenium.Stop();
            }
            catch (Exception)
            {
                // Ignore errors if unable to close the browser
            }

            seleniumRcProcess.Kill();
            webServerProcess.Kill();
        }
 public void SearchAndWaitBySeleniumRemoteControl()
 {
     //not working on latest IE and FireFox versions
     ISelenium sel = new DefaultSelenium("localhost",4444, "*iehta", "http://www.google.com");
     sel.Start();
     sel.Open("http://www.google.com/");
     sel.Type("q", "FitNesse");
     sel.Click("btnG");
     sel.WaitForPageToLoad("3000");
 }
Beispiel #3
0
        static void Main(string[] args)
        {
            HtmlDocument doc = new HtmlDocument();
            List<string> list = new List<string>();
            HashSet<string> listposters = new HashSet<string>();
            int forumNumber = 0;
            string forumAddress = "";
            //List<string> list = new List<string>();
            ISelenium sel = new DefaultSelenium("localhost", 4444, "*chrome", forumAddress);
            sel.Start();
            sel.WindowMaximize();
            sel.Open("/");
            sel.Click("id=loginlink");
            sel.WaitForPageToLoad("30000");
            sel.Type("id=username", "");
            sel.Type("id=password", "");
            sel.Click("id=submit");
            sel.WaitForPageToLoad("30000");


            for (int y = 1; y < 14; y++)
            {
                sel.Open(string.Format("/vbulletin/forumdisplay.php?f=" + forumNumber + "&order=desc&page={0}", y));
                sel.WaitForPageToLoad("30000");

                var src = sel.GetHtmlSource();

                doc.LoadHtml(src);

                var links = doc.DocumentNode.SelectNodes("//a[@href]");

                var posters = from i in links
                              where i.OuterHtml.Contains("whoposted")
                              select i;

                var ln = from o in posters
                         select o.OuterHtml.ToString();

                foreach (var item in ln)
                {
                    LinkItem i = new LinkItem();


                    Match m2 = Regex.Match(item, @"href=\""(.*?)\""",
                    RegexOptions.Singleline);
                    if (m2.Success)
                    {
                        i.Href = m2.Groups[1].Value;
                    }

                    list.Add(i.Href.Replace("&amp;", "&"));
                }

            }

            foreach (var it in list)
            {
                sel.Open(string.Format("vbulletin/{0}", it));
                sel.WaitForPageToLoad("30000");

                var src = sel.GetHtmlSource();

                doc.LoadHtml(src);

                var links = doc.DocumentNode.SelectNodes("//a[@href]");

                var posters = from i in links
                              where i.OuterHtml.Contains("member")
                              select i;

                var ln = from o in posters
                         select o.InnerHtml.ToString();

                foreach (var item in ln)
                {
                    listposters.Add(item);
                }
            }


            sel.Close();



            //var links = doc.DocumentNode.SelectNodes("//a[@href]");
            //var links2 = doc.DocumentNode.G
            //var posters = from i in links
            //              where i.OuterHtml.Contains("lastposter")
            //              select i;

            //var link = from o in posters
            //           select o.OuterHtml;

            System.IO.File.WriteAllLines(@"C:\Users\William\Documents\CsharpRandom\SeleniumTest\AllPosters.txt", listposters);

            Console.Read();
        }