FluentAutomation icon indicating copy to clipboard operation
FluentAutomation copied to clipboard

I.Find or I.FindMultiple works only on items that are visible on the UI.

Open mahwishs opened this issue 11 years ago • 5 comments

I am working on a drop down that is non standard. It is a select with Chosen jQuery style applied to it. The jsfiddle has an example of the drop down i am working with. http://jsfiddle.net/mahwishs/w2KR4/

My goal is to select something from this drop down using the value.

So i tried to use the I.FindMultiple("select#dropdown option[value=2]")() I was hoping to see the value and the text property hydrated but no attributes are hydrated.

I was hoping to select the dropdown Item3 using the following code

 string value = "9";
 var hiddenSelect = I.FindMultiple("select#dropdown option")().ToList();
 for (int i = 1; i <= hiddenSelect.Count; i++)
        {
            if (hiddenSelect[i - 1].Value == value)
            {
                var chosenDropdown = I.Find(string.Format("#dropdown_chosen ul.chosen-results li[data-option-array-index={0}]", i - 1));
                I.Click(chosenDropdown);
            }
        }

mahwishs avatar Mar 07 '14 21:03 mahwishs

Selenium has a hard requirement that an element must be Displayed (height, width > 0 && visibility != hidden && display != none) and to be interacted with.

Having said that I will see what we can do in FluentAutomation to support this scenario. The jsFiddle will prove extremely helpful with this, thanks!

stirno avatar Mar 07 '14 21:03 stirno

I am trying to find a good work around. I was reading a stack over flow that pointed me to a possibility of running a script on the page. https://github.com/stirno/FluentAutomation/issues/61

I was wondering if that was possible out of the box yet.

mahwishs avatar Mar 07 '14 22:03 mahwishs

If you extend FluentTest<T> instead of FluentTest, you can use the this.Provider property to access the active WebDriver instance and do things not directly supported by Fluent yet.

public void SampleTest : FluentTest<IWebDriver>
{
     public void Test() {
         var webDriver = this.Provider;
     }
}

This should open up options like executing JavaScript against the page to find your elements, etc as a near-term fix while we get something proper implemented for you.

We have not implemented actual JS execution in the API though. Its just a tad bit dangerous in terms of the fragility of tests and we like to stick to things users could reasonably do.

stirno avatar Mar 07 '14 22:03 stirno

OK, I'm not proud of this code, but it did work.

        I.Click("#PasswordQuestionId_chosen");
        I.Press("{DOWN}");
        I.Press("{DOWN}");
        I.Press("{DOWN}");  //Sigh.
        I.Press("{ENTER}");

It also has the advantage of being something actual users do. At least, actual users who are really lazy.

ghost avatar May 28 '14 22:05 ghost

Somewhat reminiscent of the Konami Code, so at least theres that! :)

stirno avatar May 28 '14 22:05 stirno