Beispiel #1
0
            protected bool UploadFile(string filename, string buttonType)
            {
                string locator = String.Format("//div[@id='{0}']/input[@type='file']", buttonType);

                string varToWaitFor = "";

                switch (buttonType)
                {
                case UploadButtonIdentifier.MODEL_UPLOAD:
                    varToWaitFor = "ModelUploadFinished";
                    break;

                case UploadButtonIdentifier.SCREENSHOT_VIEWABLE:
                    varToWaitFor = "ViewableThumbnailUpload.Finished";
                    break;

                case UploadButtonIdentifier.SCREENSHOT_RECOGNIZED:
                    varToWaitFor = "RecognizedThumbnailUpload.Finished";
                    break;

                case UploadButtonIdentifier.DEVLOGO:
                    varToWaitFor = "DevLogoUpload.Finished";
                    break;

                case UploadButtonIdentifier.SPONSORLOGO:
                    varToWaitFor = "SponsorLogoUpload.Finished";
                    break;

                default:
                    verificationErrors.Append("UploadButtonIdentifier is not recognized. ");
                    return(false);
                }

                string varHandle = String.Format("selenium.browserbot.getCurrentWindow().{0}", varToWaitFor);

                selenium.AddScript(varHandle + " = false;", "UploadResetter_" + buttonType);
                selenium.Type(locator, filename);
                try
                {
                    selenium.WaitForCondition(varHandle + " == true", "120000");
                    return(true);
                }
                catch (SeleniumException e)
                {
                    verificationErrors.Append(e.Message);
                    return(false);
                }
            }