コード例 #1
0
 public static void VerifyElementExists(WebItem webitem)
 {
     IWebElement element = TestFramework.FindElement(webitem);
     if (element != null)
     {
         WriteLog.WriteLogToFile("Element with xPath : " + webitem.xPath + " was found", true);
     }
     else
     {
         WriteLog.WriteLogToFile("Warning! Element with xPath : " + webitem.xPath + " was NOT found", true);
         throw new Exception("Element with xPath: " + webitem.xPath + " doesn't exist");
     }
 }
コード例 #2
0
 public static void VerifyElementNotExists(WebItem webitem)
 {
     IWebElement element = TestFramework.FindElement(webitem);
     if (element == null)
     {
         WriteLog.WriteLogToFile("Success. Element with xPath : " + webitem.xPath + " was not found", true);
     }
     else
     {
         WriteLog.WriteLogToFile("Warning! Element with xPath : " + webitem.xPath + " was found", true);
         throw new Exception("Element with xPath: " + webitem.xPath + " exists, but it should not!");
     }
 }
コード例 #3
0
    // Function verify text on page after user logged with text on xml file (25.06 12:09)
    public static void VerifyTextInTheElement(string text, WebItem webitem)
    {
        IWebElement element = TestFramework.FindElement(webitem);

        if (element.Text.Contains(text))
        {
            WriteLog.WriteLogToFile("Text \"" + text + "\" in the element with xPath : " + webitem.xPath + " was found", true);
        }
        else
        {
            WriteLog.WriteLogToFile("Warning! Text \"" + text + "\" in the element with xPath : " + webitem.xPath + " was NOT found", true);
            throw new Exception("Text \"" + text + "\" in the element with xPath : " + webitem.xPath + " was NOT found");
        }
    }
コード例 #4
0
 // Methods
 public string URLFor(WebItem obj, string EventName)
 {
 }
コード例 #5
0
ファイル: WebAssetLoader.cs プロジェクト: benloong/recipes
    IEnumerator WorkerCoroutine(WebItemRequest request)
    {
        string filepath = GetCachePath(request.url, request.version);

        bool exists = System.IO.File.Exists(filepath);
        string wwwpath = request.url;
        if(exists) {
            System.Uri uri = new System.Uri(filepath);
            wwwpath = uri.AbsoluteUri;
        }

        using(WWW www = new WWW(System.Uri.EscapeUriString(wwwpath))) {
            downloadingList.Add(request);
            float timeout = Time.realtimeSinceStartup;
            while(!www.isDone) {
                if(request.onProgress != null) request.onProgress(www.progress);
                yield return null;

                if(Time.realtimeSinceStartup - timeout > 1f && www.progress == 0) {
                    downloadingList.Remove(request);
                    if(request.onComplete != null) request.onComplete(false, null);
                    yield break;
                }
            }
            downloadingList.Remove(request);
            if(www.error != null) {
                Debug.LogWarning("cannot open url: " + wwwpath + " " + www.error);
                if(request.onComplete != null) request.onComplete(false, null);
                yield break;
            }
            WebItem item = new WebItem();
            item.url = request.url;
            item.type = request.type;
            item.version = request.version;

            if(item.type == typeof(Texture)) {
                item.Item = www.textureNonReadable;
            }
            else if(item.type == typeof(AssetBundle)) {
                item.Item = www.assetBundle;
            }
            else if(item.type == typeof(AudioClip)) {
                item.Item = www.audioClip;
            }

            cache[item.url] = item;
            item.AddRef();
            if(request.onComplete != null) request.onComplete(true, item);
            item.Release();

            //check need write to disk
            if(!exists) {
                //clear old version data
                var parentDir = System.IO.Directory.GetParent(filepath);
                var files = parentDir.GetFiles();
                foreach(var f in files) {
                    f.Delete();
                }
                //write new version data
                using (var fs = System.IO.File.OpenWrite(filepath)) {
                    Debug.Log(filepath);
                    fs.Write(www.bytes, 0, www.bytes.Length);
                    fs.Flush();
                    fs.Close();
                }
            }
        }
    }