SmeeK153 / flash-selenium

Automatically exported from code.google.com/p/flash-selenium
0 stars 0 forks source link

C# Element not found for flash #44

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
I would like to have a test that would verify a flash game loads when coming to 
a website.  When i run my code, it gives me an error saying the element of the 
flash game ID is not found.  I found the ID be using xpath.
But there is an ad before the flash game that lasts 20 seconds and it is giving 
me this error before the 20 seconds is up.  So i think i need a way to wait.  

Code i am using:

using System;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using NUnit.Framework;
using Selenium;
using FlashSelenium;

namespace SeleniumTests
{
    [TestFixture]
    public class Untitled
    {
        private FlashSelenium.FlashSelenium flashApp;
        private ISelenium selenium;
        private StringBuilder verificationErrors;
        private static String URL = "http://www.greatdaygames.com/";

        [SetUp]
        public void SetupTest()
        {

            selenium = new DefaultSelenium("localhost", 4444, "*chrome", URL);
            selenium.Start();
            verificationErrors = new StringBuilder();
        }

        [TearDown]
        public void TeardownTest()
        {
            try
            {
                selenium.Stop();
            }
            catch (Exception)
            {
                // Ignore errors if unable to close the browser
            }
            Assert.AreEqual("", verificationErrors.ToString());
        }

        [Test]
        public void FlashLoad()
        {
            selenium.Open("/");
            selenium.Click("//form[@id='aspnetForm']/center/div/div/div[3]/div[2]/div[2]/div[1]/div[1]/div[2]/div/a/span");
            selenium.WaitForPageToLoad("30000");
            selenium.Click("//form[@id='aspnetForm']/center/div/div/div[2]/div[2]/div[1]/div[3]/div/a[1]");
            selenium.WaitForPopUp("", "30000");
            flashApp = new FlashSelenium.FlashSelenium(selenium, "flashGameID");
            Assert.Equals(100, flashApp.PercentLoaded());
            }

        }
    }
}

Original issue reported on code.google.com by katidjac...@gmail.com on 2 Sep 2010 at 5:16

GoogleCodeExporter commented 8 years ago
Hello, I think you can try Thread.sleep(20000); to sleep 20 seconds.

Regards,

Lucas

Original comment by lucassap...@gmail.com on 10 Jan 2011 at 3:08