示例#1
0
        public RepositoryPage OpenReadme()
        {
            Waiter.UntilElementIsClickable(By.LinkText("README.md"), 10);
            Clicker.Click(By.LinkText("README.md"));

            return(this);
        }
示例#2
0
        private void StartClicking(object sender, KeyPressEventArgs keyEventArguments)
        {
            if (keyEventArguments.KeyChar == 'p' && !IsClickingEnabled)
            {
                IColourPicker colourPicker  = new ColourPicker();
                IVideoDisplay display       = new WindowsScreen();
                IVideoDisplay currentWindow = WindowsApplication.GetForeground();
                ICursor       cursor        = new WindowsCursor();
                Color         colour        = colourPicker.GetFromDisplayPosition(display, cursor.GetPosition());
                IPixelFinder  pixelFinder   = new PixelFinder();

                IClicker clicker = new Clicker();

                Thread clickingThread = new Thread(() =>
                {
                    IsClickingEnabled = true;
                    while (IsClickingEnabled)
                    {
                        var clickedPosition = pixelFinder.FindPixelPosition(currentWindow, colour);

                        if (clickedPosition.HasValue)
                        {
                            clicker.Click((int)currentWindow.Handle, clickedPosition.Value);
                        }

                        Thread.Sleep(TimeSpan.FromSeconds(1));
                    }
                });

                clickingThread.Start();
            }
        }
示例#3
0
        public void NewPullRequest()
        {
            string newPullRequestXPath = "//div[@class='repository-content ']/div/div/a";

            Waiter.UntilElementIsClickable(By.XPath(newPullRequestXPath), 10);
            Clicker.Click(By.XPath(newPullRequestXPath));
        }
示例#4
0
        void OnMouseDown(MouseButtonDownEventArgs e)
        {
            if (currentBuilder == null)
            {
                if (ui.UIHovering)
                {
                    return;
                }

                var raycast = input.CursorRaycast();
                foreach (var result in raycast)
                {
                    for (Node current = result.Node; current != Level.LevelNode && current != null; current = current.Parent)
                    {
                        if (!Level.TryGetBuilding(current, out IBuilding building))
                        {
                            continue;
                        }

                        Clicker clicker = null;
                        if ((clicker = building.GetDefaultComponent <Clicker>()) != null)
                        {
                            clicker.Click(e.Button, e.Buttons, e.Qualifiers);
                            return;
                        }
                    }
                }
            }
            else
            {
                currentBuilder.OnMouseDown(e);
            }
        }
示例#5
0
        public RepositoryPage CreatePullRequest()
        {
            string CreatePullRequestButtonXPath = "//div[@class='form-actions']/button";

            Waiter.UntilElementIsClickable(By.XPath(CreatePullRequestButtonXPath), 10);
            Clicker.Click(By.XPath(CreatePullRequestButtonXPath));
            return(this);
        }
示例#6
0
 public RepositoryPage CommitToNewBranch()
 {
     Waiter.UntilElementIsPresent(By.XPath("//dd/div[2]/label/input"), 10);
     Clicker.Click(By.XPath("//dd/div[2]/label/input"));
     Waiter.UntilElementIsClickable(By.Id("submit-file"), 5);
     Clicker.Click(By.Id("submit-file"));
     return(this);
 }
示例#7
0
 public void CreateSimpleRepository()
 {
     Waiter.UntilElementIsClickable(By.XPath(repoNametxtbxXpath), 10);
     TextBox.SendToTextBox(By.XPath(repoNametxtbxXpath), TestBase.repositoryName);
     Clicker.Click(By.Id("repository_auto_init"));
     Waiter.UntilElementIsClickable(By.XPath(createRepoButtonXpath), 10);
     Clicker.Click(By.XPath(createRepoButtonXpath));
     Assert.IsTrue(driver.PageSource.Contains("README.md"));// assertion to change because it's not nice
 }
示例#8
0
 public MainPage LogIn()
 {
     Waiter.UntilElementIsPresent(By.Id("login_field"), 10);
     TextBox.SendToTextboxById("login_field", userName);
     TextBox.SendToTextboxById("password", password);
     Clicker.Click(By.XPath("//*[@type='submit']"));
     Assert.IsTrue(driver.PageSource.Contains("GitHub"));
     return(new MainPage());
 }
示例#9
0
    void Autoclick()
    {
        timeUntilClick++;
        clicker.Click(clickOverflowBonus);

        if (tierHandler.tier >= 4)
        {
            bonus += BonusIncrease() * clickOverflowBonus;
        }
    }
示例#10
0
    private IEnumerator DoClicks(TutorialMessage message)
    {
        foreach (var click in message.Clicks)
        {
            clicker.Click(click);
            tapAnimation.Play(click);
            yield return(new WaitForSeconds(message.ClickInterval));
        }

        locked = false;
    }
示例#11
0
        public RepositoryPage EditReadme()
        {
            string editButtonXPath = "//button[@aria-label='Edit this file']";
            string textXPath       = "//div[@class='CodeMirror-lines']";

            Waiter.UntilElementIsClickable(By.XPath(editButtonXPath), 10);
            Clicker.Click(By.XPath(editButtonXPath));
            Clicker.Click(By.XPath(textXPath));
            action.SendKeys("abc").Perform();


            return(this);
        }
示例#12
0
        public RepositoryPage MergePullRequest()
        {
            string mergeButtonXpath   = "//div[@class='merge-message']//button";
            string confirmButtonXpath = "//*[@id='partial-pull-merging']/div[1]/form/div[2]/div[2]/div/div[1]/button";

            Waiter.UntilElementIsClickable(By.XPath(mergeButtonXpath), 10);
            Clicker.Click(By.XPath(mergeButtonXpath));

            Waiter.UntilElementIsClickable(By.XPath(confirmButtonXpath), 10);
            Clicker.Click(By.XPath(confirmButtonXpath));
            Waiter.UntilElementIsPresent(By.XPath("//*[@id='partial-pull-merging']/form/div[2]/div/div/h4"), 10);
            Assert.IsTrue(driver.PageSource.Contains("Pull request successfully merged and closed"));
            return(this);
        }
示例#13
0
        public MainPage DeleteRepository()
        {
            string      deleteButtonXPath = "//ul/li[4]/button";
            string      modalDialogXPath  = "//ul/li[4]/div[1]//div[@class='Box-body']";
            string      inputXPath        = "//ul/li[4]/div[1]//div[@class='Box-body']/form/p/input";
            IWebElement modalDialog       = driver.FindElement(By.XPath(modalDialogXPath));

            Waiter.UntilElementIsClickable(By.XPath(deleteButtonXPath), 10);
            Clicker.Click(By.XPath(deleteButtonXPath));
            modalDialog.Click();
            Waiter.UntilElementIsPresent(By.XPath(inputXPath), 10);
            TextBox.SendToTextBox(By.XPath(inputXPath), repositoryName + Keys.Enter);
            Waiter.UntilElementIsClickable(By.XPath("//button[@aria-label='Dismiss this message']"), 10);
            Assert.IsTrue(driver.PageSource.Contains("was successfully deleted."));
            return(new MainPage());
        }
示例#14
0
文件: Extensions.cs 项目: lr030/ML
        public static void CompileAllPeoplePermissions(this IZenOrchestrator source)
        {
            var people = source.GetPeople();

            var c = new Clicker("Compiling Person permissions", people);

            Parallel.ForEach(people, new ParallelOptions {
                MaxDegreeOfParallelism = 10
            }, zenPerson =>
            {
                c.Click();
                zenPerson.Permissions = source.GetPermissionsByPerson(zenPerson).Select(i => i.FullCode).ToList();
            });

            c.End();

            source.SavePerson(people);
        }
示例#15
0
        public RepositoryPage OpenRepository()
        {
            Clicker.Click(By.LinkText(repositoryName));

            return(new RepositoryPage());
        }
示例#16
0
文件: Data.cs 项目: lr030/ML
        private static BulkDataOperation <T> BulkExecute(EActionType type, IEnumerable <T> models, Mutator mutator = null, bool rawMode = false)
        {
            ValidateState(type);

            var    logStep = "";
            object logObj  = null;

            if (models == null)
            {
                return(null);
            }

            var modelSet   = models.ToList();
            var modelCount = modelSet.Count;

            var silent = modelCount == 1 || Info <T> .Settings.Silent;

            var _timed = new TimeLog();

            if (modelSet.Count == 0)
            {
                return(null);
            }

            var resultPackage = new BulkDataOperation <T> {
                Type = type
            };

            // First let's obtain any ServiceTokenGuid set by the user.

            lock (_bulkSaveLock)
            {
                try
                {
                    var     successSet = new List <T>();
                    var     failureSet = new List <T>();
                    Clicker logClicker = null;

                    _timed.Start($"{type} bulk [Warm-up]", !silent);
                    if (!silent)
                    {
                        logClicker = modelSet.GetClicker(_timed.CurrentMessage, !silent);
                    }

                    resultPackage.Control = new ConcurrentDictionary <string, DataOperationControl <T> >();

                    var paralelizableClicker = logClicker;

                    if (!rawMode)
                    {
                        Parallel.ForEach(modelSet, new ParallelOptions {
                            MaxDegreeOfParallelism = 5
                        }, item =>
                        {
                            paralelizableClicker?.Click();

                            if (item.IsNew())
                            {
                                var tempKey = mutator?.KeyPrefix + item.ToJson().Sha512Hash();

                                if (resultPackage.Control.ContainsKey(tempKey))
                                {
                                    if (!silent)
                                    {
                                        Current.Log.Warn <T>(_timed.Log($"    [Warm-up] duplicated key: {tempKey}"));
                                    }
                                    failureSet.Add(item);
                                }
                                else
                                {
                                    resultPackage.Control[tempKey] = new DataOperationControl <T> {
                                        Current = item, IsNew = true, Original = null
                                    };
                                }

                                return;
                            }

                            var modelKey = mutator?.KeyPrefix + item.GetDataKey();

                            if (resultPackage.Control.ContainsKey(modelKey))
                            {
                                if (!silent)
                                {
                                    Current.Log.Warn <T>(_timed.Log($"Repeated Identifier: {modelKey}. Data: {item.ToJson()}"));
                                }
                                return;
                            }

                            resultPackage.Control[modelKey] = new DataOperationControl <T> {
                                Current = item
                            };
                        });

                        logClicker?.End();

                        _timed.Log($"{type} bulk  [Before]", false);

                        logClicker = modelSet.GetClicker(_timed.CurrentMessage);

                        logStep = "obtaining original keys";
                        var originalKeys = resultPackage.Control.Where(controlItem => !controlItem.Value.IsNew).Select(controlPair => controlPair.Key).ToList();

                        logStep = "obtaining original models";
                        var originalSet = Get(originalKeys).ToList();

                        logStep = _timed.Log("Populating Control structure");
                        var originalMap = originalSet.ToDictionary(i => i.GetDataKey(), i => i).ToList();

                        foreach (var item in originalMap)
                        {
                            resultPackage.Control[item.Key].Original = item.Value;
                        }

                        logStep = "processing Control structure";

                        foreach (var controlItem in resultPackage.Control)
                        {
                            if (!silent)
                            {
                                logClicker.Click();
                            }

                            var currentModel  = controlItem.Value.Current;
                            var originalModel = controlItem.Value.Original;

                            var canProceed = true;

                            logStep = "checking if model is new";

                            if (!controlItem.Value.IsNew)
                            {
                                logObj = currentModel;

                                originalModel = type == EActionType.Remove ? ProcBeforePipeline(EActionType.Remove, EActionScope.Model, mutator, currentModel, originalModel) : ProcBeforePipeline(controlItem.Value.IsNew ? EActionType.Insert : EActionType.Update, EActionScope.Model, mutator, currentModel, originalModel);

                                if (originalModel == null)
                                {
                                    failureSet.Add(currentModel);
                                    controlItem.Value.Success = false;
                                    controlItem.Value.Message = "Failed ProcBeforePipeline";
                                    canProceed = false;
                                }
                            }
                            else
                            {
                                if (type == EActionType.Remove) // So we're removing a New object. Just ignore.
                                {
                                    failureSet.Add(currentModel);
                                    controlItem.Value.Success = false;
                                    controlItem.Value.Message = $"Invalid {type} operation: Record is New()";
                                    canProceed = false;
                                }
                                else
                                {
                                    originalModel = currentModel;
                                }
                            }

                            if (canProceed)
                            {
                                logStep = "Adding model to process list";
                                logObj  = currentModel;

                                successSet.Add(originalModel);

                                if (type == EActionType.Remove)
                                {
                                    originalModel.BeforeRemove();
                                }
                                else
                                {
                                    if (!originalModel.IsNew())
                                    {
                                        originalModel.BeforeUpdate();
                                    }
                                    else
                                    {
                                        originalModel.BeforeInsert();
                                    }

                                    originalModel.BeforeSave();
                                }

                                controlItem.Value.Success = true;
                            }
                        }

                        if (!silent)
                        {
                            logClicker.End();
                        }

                        logStep = _timed.Log($"{type} {successSet.Count} models");

                        if (type == EActionType.Remove)
                        {
                            Info <T> .Settings.Adapter.BulkRemove(successSet);
                        }
                        else
                        {
                            Info <T> .Settings.Adapter.BulkUpsert(successSet);
                        }

                        if (!silent)
                        {
                            logClicker = modelSet.GetClicker($"{type} bulk   [After]");
                        }

                        logStep = _timed.Log("post-processing individual models");

                        Parallel.ForEach(resultPackage.Control.Where(i => i.Value.Success), new ParallelOptions {
                            MaxDegreeOfParallelism = 5
                        }, controlModel =>
                        {
                            var key = controlModel.Key;
                            if (!silent)
                            {
                                logClicker.Click();
                            }

                            if (type == EActionType.Remove)
                            {
                                controlModel.Value.Current.AfterRemove();
                                ProcAfterPipeline(EActionType.Remove, EActionScope.Model, mutator, controlModel.Value.Current, controlModel.Value.Original);
                            }
                            else
                            {
                                if (controlModel.Value.IsNew)
                                {
                                    controlModel.Value.Current.AfterInsert(key);
                                }
                                else
                                {
                                    controlModel.Value.Current.AfterUpdate(key);
                                }

                                controlModel.Value.Current.AfterSave(key);

                                ProcAfterPipeline(controlModel.Value.IsNew ? EActionType.Insert : EActionType.Update, EActionScope.Model, mutator, controlModel.Value.Current, controlModel.Value.Original);
                            }

                            CacheFactory.FlushModel <T>(key);
                        });

                        resultPackage.Success = successSet;
                        resultPackage.Failure = failureSet;

                        logStep = _timed.Log($"{type} bulk operation complete. Success: {resultPackage.Success.Count} | Failure: {resultPackage.Failure.Count}");

                        if (!silent)
                        {
                            logClicker.End();
                        }
                        _timed.End(false);
                    }
                    else //RawMode means no triggers. AT ALL.
                    {
                        if (type == EActionType.Remove)
                        {
                            Info <T> .Settings.Adapter.BulkRemove(modelSet);
                        }
                        else
                        {
                            Info <T> .Settings.Adapter.BulkUpsert(modelSet);
                        }
                    }

                    return(resultPackage);
                }
                catch (Exception e)
                {
                    if (!silent)
                    {
                        Current.Log.Add <T>(e);
                    }
                    var ex = new Exception($"{type} - Error while {logStep} {logObj?.ToJson()}: {e.Message}", e);

                    _timed.End();
                    throw ex;
                }
            }
        }