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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

automated UI tests: Find.Element issue #246

Open
wijdenchebbi opened this issue Apr 24, 2016 · 5 comments
Open

automated UI tests: Find.Element issue #246

wijdenchebbi opened this issue Apr 24, 2016 · 5 comments

Comments

@wijdenchebbi
Copy link

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.

@robdmoore
Copy link
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 [email protected] 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

@wijdenchebbi
Copy link
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,

@wijdenchebbi
Copy link
Author

wijdenchebbi commented May 3, 2016

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)

@robdmoore
Copy link
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.

@wijdenchebbi
Copy link
Author

wijdenchebbi commented May 10, 2016

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants