Skip to content

automated UI tests: Find.Element issue #246

Open

Description

@wijdenchebbi

Hello,

I have a problem in my UI Tests: i used Find.Element(By.LinkText()) and Find.Element(By.CssSelector()) and The tests run fine in local (VS2012 ASP.Net project) but when i deploy my tests in the server i reseive the errors of buid in some tests:
Information: [Error] 'TestStack.Seleno.PageObjects.Actions.ElementFinder' Error invoking ElementFinder.Element
Information: [Error] 'TestStack.Seleno.PageObjects.Actions.ElementFinder' OpenQA.Selenium.NoSuchElementException: Unable to locate element: {"method":"css selector","selector":""} at TestStack.Seleno.Extensions.WebDriverExtensions.ElementWithWait(IWebDriver driver, Func`2 elementIsFound, TimeSpan maxWait)

Information: [Error] 'TestStack.Seleno.PageObjects.Actions.ElementFinder' OpenQA.Selenium.NoSuchElementException: Unable to locate element: {"method":"LinkText"} at TestStack.Seleno.Extensions.WebDriverExtensions.ElementWithWait(IWebDriver driver, Func`2 elementIsFound, TimeSpan maxWait)

I tried to run the tests in different versions of Visual Studio 2012,2013, and 2015 and i find the same error of build but in different tests.

I don't know why find.element doesn't work sometimes?

Thanks.

Activity

  1. robdmoore commented on Apr 25, 2016

    @robdmoore
    Member

    What is running the tests on the build server? TeamCity? VSTS? ...?

    Does it always fail on the build server or is it intermittent?

    Have you added code to take screenshots? What do the screenshots show?

    On 25 Apr 2016, at 5:05 am, wijdenchebbi notifications@github.com wrote:

    Hello,

    I have a problem in my UI Tests: i used Find.Element(By.LinkText()) and Find.Element(By.CssSelector()) and The tests run fine in local (VS2012 ASP.Net project) but when i deploy my tests in the server i reseive the errors of buid in some tests:
    Information: [Error] 'TestStack.Seleno.PageObjects.Actions.ElementFinder' Error invoking ElementFinder.Element
    Information: [Error] 'TestStack.Seleno.PageObjects.Actions.ElementFinder' OpenQA.Selenium.NoSuchElementException: Unable to locate element: {"method":"css selector","selector":""} at TestStack.Seleno.Extensions.WebDriverExtensions.ElementWithWait(IWebDriver driver, Func`2 elementIsFound, TimeSpan maxWait)

    Information: [Error] 'TestStack.Seleno.PageObjects.Actions.ElementFinder' OpenQA.Selenium.NoSuchElementException: Unable to locate element: {"method":"LinkText"} at TestStack.Seleno.Extensions.WebDriverExtensions.ElementWithWait(IWebDriver driver, Func`2 elementIsFound, TimeSpan maxWait)

    I tried to run the tests in different versions of Visual Studio 2012,2013, and 2015 and i find the same error of build but in different tests.

    I don't know why find.element doesn't work sometimes?

    Thanks.

    —
    You are receiving this because you are subscribed to this thread.
    Reply to this email directly or view it on GitHub

  2. wijdenchebbi commented on Apr 25, 2016

    @wijdenchebbi
    Author

    Hi Robdmoore
    the tests are running by a powershell script : VSTest
    On the build server:it is intermittent,
    And i didn't use the screenshots, how can i use it?

    Thanks,

  3. wijdenchebbi commented on May 3, 2016

    @wijdenchebbi
    Author

    Hi,

    I test the devexpress GridView loading: How can i add Wait.Until the loading of the callback is completed.

    I used WaitFor.AjaxCallsToComplete(); but i get this error: $ is undefined (UnexpectedJavaScriptError)

  4. robdmoore commented on May 8, 2016

    @robdmoore
    Member

    That'll be because you don't have jQuery loaded on the page. Some of the things in Seleno like the waitfor.ajaxcallstocomplete depend on jQuery being there.

    The fact it's intermittent probably means it's a timing issue. It may happen on the build server rather than local because the build server is a bit slower so things take longer to load.

    If you want to put in a wait until a particular element is there then look into the WebDriverWait class (it's part of Selenoium.WebDriver, which Seleno wraps.

  5. wijdenchebbi commented on May 10, 2016

    @wijdenchebbi
    Author

    Thanks for your reply,

    In fact, i get the issue of JavaScriptError in local not in the build server.

    In the server build, i had another issue of find element: i replaced it by
    wait.Until(ExpectedConditions.ElementIsVisible(By.Id("id")));but it didn't work

    So, i used the way to execute javascript code to click into the element: IJavaScriptExecutor js = (IJavaScriptExecutor)BrowserHost.Instance.Application.Browser; js.ExecuteScript("return document.getElementsByClassName('classname')[0].click();");

    And this time it works correctly in the server build :)

    Now, i have the same error of WaitFor.AjaxCallsToComplete(); just in local

    I tried to use another way to verify that the document is ready and the ajax call are completed by this code: WebDriverWait wait = new WebDriverWait(BrowserHost.Instance.Application.Browser, TimeSpan.FromSeconds(100)); wait.Until(d => (bool)(d as IJavaScriptExecutor).ExecuteScript("return document.readyState").ToString().Equals("complete")); wait.Until(d => (bool)(d as IJavaScriptExecutor).ExecuteScript("return jQuery.active == 0")); and i got an error( jQuery is not a function (UnexpectedJavaScriptError))

    It can be related to the navigator FireFox or the speed of the connexion?

    Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions