コード例 #1
0
        /// <summary>
        /// コンストラクタ(クラス情報コピー)
        /// </summary>
        /// <param name="auctionID">QUIQテスト項目情報</param>
        public WebTestDto(WebTestDto wt)
        {
            //シート名称
            this.sheetName = wt.sheetName;

            //テスト名称
            this.testName = wt.testName;

            //テストNo
            this.testNo = wt.testNo;

            //URLを設定
            this.url = wt.url;

            //captureSQLを設定
            this.captureSQL = wt.captureSQL;

            //値を設定
            this.formElementList = wt.formElementList;

            //ボタン名称を設定
            this.clickButtonName = wt.clickButtonName;

            //ポストバック回数
            this.postBackCnt = wt.postBackCnt;

            //Submit type
            this.submitType = wt.submitType;
        }
コード例 #2
0
        /// <summary>
        /// エビデンス取得処理を実行
        /// </summary>
        /// <param name="inValue">Excelコントローラークラス</param>
        protected override object doneImpl(object inValue)
        {
            WebTestDto webTestDto = (WebTestDto)inValue;

            //表示中のHtmlソースを取得する
            string htmlStr = webBrowserReceiver.webBrowser.DocumentText;
            //MemoryStream reader = (MemoryStream)webBrowserReceiver.webBrowser.DocumentStream;
            //byte[] bytes = reader.ToArray();
            //string htmlStr = Encoding.GetEncoding("UTF-8").GetString(bytes);

            // カレントディレクトリを取得する
            string stCurrentDir = System.IO.Directory.GetCurrentDirectory();

            //Shift JISで書き込む
            //書き込むファイルが既に存在している場合は、上書きする
            System.IO.StreamWriter sw = new System.IO.StreamWriter(
                @stCurrentDir + "\\" + "Ebidence" + "\\" + webTestDto.testNo + "_" + webTestDto.ebidenceSetMode + TMP_FILE_NAME,
                false,
                System.Text.Encoding.GetEncoding("UTF-8")); //TODO Configファイルから設定できるように修正
            //TextBox1.Textの内容を書き込む
            sw.Write(htmlStr);
            //閉じる
            sw.Close();

            //ログ出力
            setLogInfoStr("Capture", "HTML", "");

            //ダミーの値を戻す
            return(null);
        }
コード例 #3
0
        /// <summary>
        /// URLを設定
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void buttonUrlSet_Click(object sender, EventArgs e)
        {
            //一覧選択チェック
            if (!checkTestCaseListSelected())
            {
                return;
            }

            ////URLを設定
            //comboBoxUrl.Text = webTestController.getWebTestInfo(checkedListBox1.SelectedIndex).url;

            ////マニュアル実行
            //webTestController.testDoneManual(checkedListBox1.SelectedIndex, 0);


            WebBrowserEx webBrowserEx = new WebBrowserEx();

            //新しいタブウインドウを設定
            setNewWebTab(webBrowserEx);

            webTestController.webBrowser = webBrowserEx;

            ////新しいウインドウが開かれる時の動作のメソッドをハンドルに設定する
            //webBrowserEx1.NewWindow2 += new WebBrowserNewWindow2EventHandler(webBrowser_NewWindow2);

            ////Web画面表示完了イベント登録(デフォルトWebブラウザ)
            //webBrowserEx1.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(webBrowserDocumentCompleted);

            WebTestDto webTestDto = webTestController.getWebTestInfo(checkedListBox1.SelectedIndex);

            //ポストバックカウントをリセット
            documentCompletedCount = 0;

            // URLに移動
            webTestController.webBrowser.Navigate(webTestDto.url);
        }
コード例 #4
0
 /// <summary>
 /// DBキャプチャを取得する
 /// </summary>
 public void getDBCapt(WebTestDto webTest)
 {
     //dbEvidence.done(webTest);
 }
コード例 #5
0
 /// <summary>
 /// Htmlソーキャプチャを取得する
 /// </summary>
 public void getHtmlCapt(WebTestDto webTest)
 {
     captHtml.done(webTest);
 }
コード例 #6
0
 /// <summary>
 /// 画面キャプチャを取得する
 /// </summary>
 public void getWindowCapt(WebTestDto webTest)
 {
     captEvidence.done(webTest);
 }
コード例 #7
0
        /// <summary>
        /// エビデンス取得処理を実行
        /// </summary>
        /// <param name="inValue">Excelコントローラークラス</param>
        protected override object doneImpl(object inValue)
        {
            // カレントディレクトリを取得する
            string stCurrentDir = System.IO.Directory.GetCurrentDirectory();

            WebTestDto webTestDto = (WebTestDto)inValue;

            Bitmap bmp = null;

            if ("0".Equals(CAPT_MODE))
            {
                ////コントロールの外観を描画するBitmapの作成
                bmp = CaptureControl(webBrowserReceiver.webBrowser);

                //ログ出力
                setLogInfoStr("Capture", "BitMap", "Nomal1");
            }
            else if ("1".Equals(CAPT_MODE))
            {
                int w = webBrowserReceiver.webBrowser.Document.Body.ScrollRectangle.Width;
                int h = webBrowserReceiver.webBrowser.Document.Body.ScrollRectangle.Height;

                //コントロールの外観を描画するBitmapの作成
                bmp = new Bitmap(w, h);
                //キャプチャする
                webBrowserReceiver.webBrowser.DrawToBitmap(bmp, new Rectangle(0, 0, w, h));

                //ログ出力
                setLogInfoStr("Capture", "BitMap", "Nomal2");
            }
            else if ("2".Equals(CAPT_MODE))
            {
                //Activ X
                bmp = captScrollEbi(webBrowserReceiver.webBrowser);

                //ログ出力
                setLogInfoStr("Capture", "BitMap", "ActivX");
            }

            try
            {
                //Dirがあるかを確認する、ない場合は作成する
                string evidenceDirPass = stCurrentDir + "\\" + "Ebidence" + "\\";
                if (!System.IO.File.Exists(evidenceDirPass))
                {
                    System.IO.DirectoryInfo di = System.IO.Directory.CreateDirectory(evidenceDirPass);
                }

                //BitmapをSaveする
                bmp.Save(evidenceDirPass + webTestDto.testNo + "_" + webTestDto.ebidenceSetMode + ".bmp");
            }
            catch (Exception e)
            {
                //ログ出力
                setLogWarnStr("Capture", "BitMap", "エビデンスBitmapファイルの保存に失敗しました");
            }
            finally
            {
                //後始末
                bmp.Dispose();
            }

            //ダミーの値を戻す
            return(null);
        }
コード例 #8
0
        /// <summary>
        /// テスト情報を取得VOを作成する
        /// </summary>
        /// <param name="oXls"></param>
        /// <param name="testFilePass"></param>
        //public List<WebTestDto> makeTestInfoVO(Microsoft.Office.Interop.Excel.Application oXls, string testFilePass)
        public List <WebTestDto> makeTestInfoVO(string testFilePass)
        {
            //テスト情報
            WebTestDto webTest;

            //テストNo
            string no = "0";

            //テスト名称
            string testName = "";

            // URL
            string url = "";

            // SubmitボタンName
            string buttonName = "";

            // PostBack回数
            string postBackCntStr = "";
            int    postBackCnt    = 0;

            //Submit Type
            string submitTypeStr = "";
            int    submitType    = 0;

            bool isNumber = false;

            Dictionary <string, int> idDictionary = new Dictionary <string, int>();

            //画面設定項目 マスタ
            List <FormElement> webTestDictionaryList = null;

            //画面設定項目 設定
            List <FormElement> webTestDictionaryListSet = null;

            //テスト情報クリア
            webTestList = new List <WebTestDto>();

            //Excelファイルに設定されているテスト項目を読み取り
            //ExcelController excelController = new ExcelController(oXls);
            ExcelController excelController = new ExcelController();

            excelController.setExcelFilePass(testFilePass);

            //ファイルをOpenする
            excelController.openExcelFile();

            //シートリスト情報を取得
            List <String> sheetList = excelController.getSheetList();

            //エラーメッセージ文字列
            string errorMsgStr = "";

            try
            {
                //シートごとループ
                foreach (String sheetName in sheetList)
                {
                    string captureSQL = "";

                    // URL取得
                    url          = excelController.getValue(sheetName, CommonConst.CSV_URL_COL, CommonConst.CSV_URL_ROW);
                    errorMsgStr += checkAndSetCsvErrorMsgStrValNotSet(url, "テスト対象URL", sheetName, CommonConst.CSV_URL_COL, CommonConst.CSV_URL_ROW);

                    // DBエビデンス取得SQL
                    captureSQL = excelController.getValue(sheetName, 3, 3);

                    //設定カラム名称を取得
                    List <string> colNameList      = new List <string>();
                    int           rowSetStart      = 10;
                    int           rowEbidenceStart = 10;
                    int           row       = 10;
                    int           inOutFlag = 0; // IN
                    int           index     = 0;

                    //設定カラム名称を取得、マスタ情報を作成
                    webTestDictionaryList = new List <FormElement>();
                    for (row = rowSetStart; !string.IsNullOrWhiteSpace(excelController.getValue(sheetName, 1, row)); row++)
                    {
                        string elementVal  = excelController.getValue(sheetName, CommonConst.TESTCASE_ELEMENT_VAL_COL, row);
                        string elementType = excelController.getValue(sheetName, CommonConst.TESTCASE_ELEMENT_TYPE_COL, row);

                        errorMsgStr += checkAndSetCsvErrorMsgStrValNotSet(elementVal, "項目値", sheetName, CommonConst.TESTCASE_ELEMENT_VAL_COL, row);
                        errorMsgStr += checkAndSetCsvErrorMsgStrValNotSet(elementType, "項目種別", sheetName, CommonConst.TESTCASE_ELEMENT_TYPE_COL, row);


                        //設定情報開始位置
                        if ("TestResoult".Equals(elementVal))
                        {
                            rowEbidenceStart = row;
                            inOutFlag        = 1; //OUT
                        }
                        else
                        {
                            switch (elementType)
                            {
                            case "TextBox":
                                webTestDictionaryList.Add(new FormElement(elementVal, "", FormElement.ElementType.TextBox, inOutFlag, index));
                                break;

                            case "DropDownList":
                                webTestDictionaryList.Add(new FormElement(elementVal, "", FormElement.ElementType.DropDownList, inOutFlag, index));
                                break;

                            case "RadioButton":
                                webTestDictionaryList.Add(new FormElement(elementVal, "", FormElement.ElementType.RadioButton, inOutFlag, index));   //ラジオボタン チェック「1」チェック外す「0」
                                break;

                            case "CheckBox":
                                webTestDictionaryList.Add(new FormElement(elementVal, "", FormElement.ElementType.CheckBox, inOutFlag, index));    //ラジオボタン チェック「1」チェック外す「0」RadioButtonと動作は同じ
                                break;

                            case "Label":
                                webTestDictionaryList.Add(new FormElement(elementVal, "", FormElement.ElementType.Label, inOutFlag, index));
                                break;

                            case "HiddenValue":
                                webTestDictionaryList.Add(new FormElement(elementVal, "", FormElement.ElementType.HiddenValue, inOutFlag, index));
                                break;

                            default:
                                errorMsgStr += setCsvErrorMsgStr("指定外の項目タイプです", sheetName, CommonConst.TESTCASE_ELEMENT_TYPE_COL, row);
                                break;
                            }
                        }

                        colNameList.Add(excelController.getValue(sheetName, 1, row));
                    }

                    // 設定値情報を取得(テスト番号が設定されている行を実行)
                    idDictionary.Clear();
                    for (int col = 3; !string.IsNullOrWhiteSpace(excelController.getValue(sheetName, col, 4)); col++)
                    {
                        int valNum = -1;

                        // テストNO取得
                        no           = excelController.getValue(sheetName, col, CommonConst.TESTCASE_TEST_NO_ROW);
                        errorMsgStr += checkAndSetCsvErrorMsgStrValNotSet(no, "テストNO", sheetName, col, CommonConst.TESTCASE_TEST_NO_ROW);

                        // テスト名称取得
                        testName     = excelController.getValue(sheetName, col, CommonConst.TESTCASE_TEST_NAME_ROW);
                        errorMsgStr += checkAndSetCsvErrorMsgStrValNotSet(no, "テスト名称", sheetName, col, CommonConst.TESTCASE_TEST_NAME_ROW);

                        // SubmitボタンID取得
                        buttonName   = excelController.getValue(sheetName, col, CommonConst.TESTCASE_SUBMIT_BUTTON_ID_ROW);
                        errorMsgStr += checkAndSetCsvErrorMsgStrValNotSet(no, "SubmitボタンID", sheetName, col, CommonConst.TESTCASE_SUBMIT_BUTTON_ID_ROW);

                        //ポストバック回数を取得
                        postBackCntStr = excelController.getValue(sheetName, col, CommonConst.TESTCASE_POSTBACK_COUNT_ROW);
                        errorMsgStr   += checkAndSetCsvErrorMsgStrValNotSet(postBackCntStr, "ポストバック回数", sheetName, col, CommonConst.TESTCASE_POSTBACK_COUNT_ROW);
                        //valueが数値かを確認
                        isNumber = int.TryParse(postBackCntStr, out postBackCnt);
                        if (!isNumber || postBackCnt < 0)
                        {
                            errorMsgStr += setCsvErrorMsgStr("ポストバック回数は、0または正の値で指定してください", sheetName, CommonConst.TESTCASE_POSTBACK_COUNT_ROW, row);
                        }

                        //Submitタイプを取得
                        submitTypeStr = excelController.getValue(sheetName, col, CommonConst.TESTCASE_SUBMIT_TYPE_ROW);
                        errorMsgStr  += checkAndSetCsvErrorMsgStrValNotSet(no, "押下ボタン種別", sheetName, col, CommonConst.TESTCASE_SUBMIT_TYPE_ROW);
                        //valueが数値かを確認
                        isNumber = int.TryParse(submitTypeStr, out submitType);
                        if (!isNumber || submitType < 0 || submitType > 1)
                        {
                            errorMsgStr += setCsvErrorMsgStr("押下ボタン種別は、Submit「1」、click「0」いずれかで指定してください", sheetName, CommonConst.TESTCASE_SUBMIT_TYPE_ROW, row);
                        }

                        // 設定項目情報取得
                        int rowSub = rowSetStart;
                        webTestDictionaryListSet = new List <FormElement>();
                        idDictionary.Clear();
                        foreach (FormElement formElement in webTestDictionaryList)
                        {
                            //エビデンス取得開始行のマーカー行はスキップする
                            if (rowEbidenceStart.Equals(rowSub))
                            {
                                rowSub++;
                            }

                            //Index の値を設定する
                            index = 0;
                            if (idDictionary.ContainsKey(formElement.id))
                            {
                                index = idDictionary[formElement.id];
                                idDictionary.Remove(formElement.id);
                            }

                            //テスト値取得
                            string valStr = excelController.getValue(sheetName, col, rowSub);

                            //テスト値妥当性確認
                            isNumber = int.TryParse(valStr, out valNum);
                            switch (formElement.elementType)
                            {
                            case FormElement.ElementType.TextBox:
                                break;

                            case FormElement.ElementType.DropDownList:
                                if (!isNumber)
                                {
                                    errorMsgStr += setCsvErrorMsgStr("Index値を数字で指定してください", sheetName, CommonConst.TESTCASE_ELEMENT_VAL_COL, row);
                                }
                                break;

                            case FormElement.ElementType.RadioButton:
                                if (!isNumber || valNum < 0 || valNum > 1)
                                {
                                    errorMsgStr += setCsvErrorMsgStr("チェック有り「1」、チェック無し「0」いずれかで指定してください", sheetName, CommonConst.TESTCASE_ELEMENT_VAL_COL, row);
                                }
                                break;

                            case FormElement.ElementType.CheckBox:
                                if (!isNumber || valNum < 0 || valNum > 1)
                                {
                                    errorMsgStr += setCsvErrorMsgStr("チェック有り「1」、チェック無し「0」いずれかで指定してください", sheetName, CommonConst.TESTCASE_ELEMENT_VAL_COL, row);
                                }
                                break;

                            case FormElement.ElementType.Label:
                                break;

                            case FormElement.ElementType.HiddenValue:
                                break;

                            default:
                                break;
                            }

                            //テストNoごとの情報を追加
                            webTestDictionaryListSet.Add(new FormElement(
                                                             formElement.id,
                                                             valStr,
                                                             formElement.elementType,
                                                             formElement.inOutFlag,
                                                             index)
                                                         );

                            //加算
                            index++;
                            idDictionary.Add(formElement.id, index);

                            rowSub++;
                        }

                        // テストデータをコマンドクラスに設定
                        webTest = new WebTestDto(
                            sheetName,
                            testName,
                            int.Parse(no),
                            url,
                            captureSQL,
                            webTestDictionaryListSet,
                            buttonName,
                            postBackCnt,
                            submitType);

                        webTestList.Add(webTest);
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            finally
            {
                //ファイルをCloseする
                excelController.closeExcelFile();
            }

            if (!string.IsNullOrEmpty(errorMsgStr))
            {
                formLog.setLogStrList(errorMsgStr);
            }

            //作成情報を返す(グローバルにも情報を保管)
            return(webTestList);
        }
コード例 #9
0
        /// <summary>
        /// テストマニュアル実行
        /// </summary>
        /// <param name="webBrowser">Formで設定されているwebBrowser</param>
        /// <param name="auctionBidNo">一覧で選択されたテスト</param>
        /// <param name="doneType">実行樹別(0:URL 1:画面設定 2:サブミット 3:エビデンス)</param>
        public void testDoneManual(int testNo, int doneType)
        {
            if (testNo < 0)
            {
                return;
            }

            //個別実行時、ウインドウが設定されていない場合チェック
            if (webBrowser == null)
            {
                return;
            }

            //テスト情報を取得
            WebTestDto webTestDto = webTestList[testNo];

            //マニュアル実行用のVOクラスを生成
            WebTestDto wtManual = new WebTestDto(webTestDto);

            switch (doneType)
            {
            case 0:
                //wtManual.url = "";                // URL情報を削除
                wtManual.formElementList = new List <FormElement>(); // 画面設定情報を削除
                wtManual.clickButtonName = "";                       // Submitボタン情報を削除
                wtManual.testNo          = 0;                        //エビデンス取得削除
                break;

            case 1:
                wtManual.url = "";                      // URL情報を削除
                //wtManual.formElementList = new List<FormElement>();    // 画面設定情報を削除
                wtManual.clickButtonName = "";          // Submitボタン情報を削除
                wtManual.testNo          = 0;           //エビデンス取得削除
                break;

            case 2:
                wtManual.url             = "";                       // URL情報を削除
                wtManual.formElementList = new List <FormElement>(); // 画面設定情報を削除
                //wtManual.clickButtonName = "";    // Submitボタン情報を削除
                wtManual.testNo = 0;                                 //エビデンス取得削除
                break;

            case 3:
                wtManual.url             = "";                       // URL情報を削除
                wtManual.formElementList = new List <FormElement>(); // 画面設定情報を削除
                wtManual.clickButtonName = "";                       // Submitボタン情報を削除
                //wtManual.testNo = 0;            //エビデンス取得削除
                break;

            default:
                break;
            }

            //テスト情報を取得
            List <WebTestDto> webTestSelectList = new List <WebTestDto>();

            webTestSelectList.Add(wtManual);

            WebTestDo WebTestDo = new WebTestDo(webTestSelectList);

            //テストを実施(スレッド実行)
            ThreadPool.QueueUserWorkItem(new WaitCallback(testDoneThread), WebTestDo);
        }