NSelene icon indicating copy to clipboard operation
NSelene copied to clipboard

Enhance error messages for failed search by condition in collection

Open yashaka opened this issue 8 years ago • 3 comments

            Open("http://todomvc4tasj.herokuapp.com/");
            S("#new-todo").SetValue("a").PressEnter();
            S("#new-todo").SetValue("c").PressEnter();

            SS("#todo-list>li").FindBy(Have.ExactText("b"))
                .DoubleClick();

fails with

Result Message:
Test method Lesson1.TodoMVCTests.TestCommonTasksFlow threw exception: OpenQA.Selenium.WebDriverTimeoutException: Timed out after 4 seconds while waiting for condition: : NSelene.Conditions.Visible Expected: True Actual: False ---> OpenQA.Selenium.NotFoundException: element was not found by conditionNSelene.Conditions.ExactText Expected: contains b Actual: c

but should be something like:

... Expected: contains b Actual: [a, c]

yashaka avatar May 10 '16 06:05 yashaka

            Open("http://todomvc4tasj.herokuapp.com/");
            S("#new-todo").SetValue("a").PressEnter();
            S("#new-todo").SetValue("c").PressEnter();

            SS("#todo-list>a").FindBy(Have.ExactText("b"))
                .DoubleClick();

And for this should be something like:

... Expected: contains b Actual: []

yashaka avatar May 10 '16 07:05 yashaka

fixed to:

OpenQA.Selenium.WebDriverTimeoutException : 
Timed out after 0.25 seconds 
while waiting entity with locator: By.Selene: (By.CssSelector: #todo-list>li).FindBy(ExactText is b) 
for condition: Visible
  Expected : True
  Actual   : False
  ----> OpenQA.Selenium.NotFoundException : element was not found in collection by condition ExactText is b
  Actual   : [a,c]

TODO: add test

yashaka avatar May 11 '16 22:05 yashaka

enhanced a bit:

OpenQA.Selenium.WebDriverTimeoutException : 
Timed out after 0.25 seconds 
while waiting entity with locator: By.Selene: (By.CssSelector: #todo-list>li).FindBy(ExactText is b) 
for condition: Visible
  Expected : True
  Actual   : False
  ----> OpenQA.Selenium.NotFoundException : element was not found in collection by condition ExactText is b
  Actual visible texts : [a,c]
  Actual html elements : [<li class="active" data-index="0">
    <div class="view">
        <input class="toggle" type="checkbox">
        <label>a</label>
        <button class="destroy"></button>
    </div>
    <input class="edit">
</li>,<li class="active" data-index="1">
    <div class="view">
        <input class="toggle" type="checkbox">
        <label>c</label>
        <button class="destroy"></button>
    </div>
    <input class="edit">
</li>]

yashaka avatar May 11 '16 23:05 yashaka