Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

SlowLoadableComponent ignores UnableToLoadMessage #8550

Closed
elgatov opened this issue Jul 19, 2020 · 6 comments
Closed

SlowLoadableComponent ignores UnableToLoadMessage #8550

elgatov opened this issue Jul 19, 2020 · 6 comments
Labels

Comments

@elgatov
Copy link
Contributor

elgatov commented Jul 19, 2020

馃悰 Bug Report

If a component load fails, the message will default to "Timed out after x seconds."

To Reproduce

Create a SlowLoadableComponent and set the UnableToLoadMessage property.

Expected behavior

If the property UnableToLoadMessage is set, the WebDriverTimeoutException should include it

Test script or set of commands reproducing this issue

using System;
using System.Diagnostics;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using OpenQA.Selenium.Support.UI;

namespace selenium_pruebas
{
    [TestClass]
    public class UnitTest1
    {
        IWebDriver driver;

        [TestMethod]
        public void TestMethod1()
        {
            driver = new ChromeDriver();

            driver.Manage().Window.Maximize();

            driver.Url = "https://www.google.com/";

            try
            {
                new GoogleAccountInformationComponent(driver).Load();
            }
            catch (WebDriverException e)
            {
                string exception = e.Message;
                string innerException = (e.InnerException != null) ? $"{e.InnerException.Message}" : string.Empty;

                Debug.WriteLine($"{exception}");
                Debug.WriteLine($"{innerException}");

                throw;
            }
        }

        [TestCleanup]
        public void TestCleanup()
        {
            if (driver != null)
            {
                driver.Quit();
                driver.Dispose();
            }
        }

        class GoogleAccountInformationComponent : SlowLoadableComponent<GoogleAccountInformationComponent>
        {
            private IWebDriver driver;

            public GoogleAccountInformationComponent(IWebDriver driver) : base(TimeSpan.FromSeconds(5))
            {
                this.driver = driver;
            }

            protected IWebElement AccountInfo => driver.FindElement(By.CssSelector("div[aria-label = 'Account Information']"));
            protected IWebElement OpenAccountInfoButton => driver.FindElement(By.CssSelector("gb_0f.gb_Za.gb_Pg.gb_i"));
            public override string UnableToLoadMessage => "Could not load 'Account Information'";

            protected override bool EvaluateLoadedStatus() => AccountInfo.Displayed;

            protected override void ExecuteLoad() => OpenAccountInfoButton.Click();
        }
    }
}

Environment

OS: Windows 10
Browser: Google Chrome
Browser version: 83.0.4103
Browser Driver version: ChromeDriver 83.0.4103
Language Bindings version: C# 3.141.0
Selenium Grid version (if applicable): N/A

@ghost ghost added the needs-triaging label Jul 19, 2020
@elgatov
Copy link
Contributor Author

elgatov commented Jul 19, 2020

This issue is a copy of #4281 with a quick and dirty code on VS with MSTest, I can provide the full solution but as it weights around 90mb I decided against uploading it.

@AutomatedTester
Copy link
Member

@elgatov do you want to offer a PR for this?

@AutomatedTester
Copy link
Member

@elgatov Did you submit this commit as a PR somewhere?

@elgatov
Copy link
Contributor Author

elgatov commented Jun 14, 2021

@AutomatedTester hi!, sorry I thought I had indeed commited a PR to solve this. It is #9572

Regards

@jimevans
Copy link
Member

Fixed in 54aba4c

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked and limited conversation to collaborators Nov 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

5 participants