While I was doing testing in Eclipse, my java program has to wait for the page in Firefox driver to load completely. Is their any way that i can tell my program to continue executing the next step without waiting?
In my professional opinion, you shouldn't do this. You should let Selenium do its duty, and make sure the page is fully loaded before you continue.
One thing to note, is that when you call click() on a WebElement, Selenium doesn't actually wait for the page to load. driver.get() does however.
What you are asking, isn't a very "common practice", so this may or may not work.
Try just setting the pageLoadTimeout "0".
driver.manage().timeouts().pageLoadTimeout(0L, TimeUnit.MILLISECONDS);
(this syntax is of course if you are using Java. you don't have the question marked as a specific language, so take it as it is and convert it to your language of choice)
Related
I'm making automated tests cases with mix of selenium and builtin keywords in Robot Framework.
I have made the:
Register Keyword To Run On Failure Screenshot On Failure
which overwrites the default behavior to create selenium-screenshot-index.png (I needed other names). Everything works fine if the keyword failing is part of the selenium library. If not (let's say custom or builtin one) the screenshot is not taken.
Is there a way, to register the keyword to run on any failure in any keyword?
Well, depending on your actual goal solution could be quite simple or require a little bit of python programming.
Simple solution. I would say that taking one screenshot in test teardown if test case failed is enough in most of the cases.
Writing custom listener interface that would grab instance of library (Selenium, OS) and depending on keyword status would take action.
I am using selenium framework to automate a web application wherein basically, driver.findElement() is commonly used. but I got the suggestion that #FindBy() works faster than driver.findElement(). suggest me which is better to use ?
When the code - PageFactory.initElements(....) is run it creates Proxy objects for all the fields which are annotated with #FindBy (or even #FindBys and #FindAll). So initially no searching of WebElements are performed.
Then if something like element.sendKeys(...) is run, the actual WebElement is searched using driver.findElement(...) before sendKeys() is run. Then if the same sendKeys() code is run the element is found again.
But if you add the CacheLookup annotation to the field then the second lookup is not performed but element is returned from the cache. So there is a performance gain. But the problem occurs in a javascript or ajax heavy page, stale element exception can show up.
For any non-trivial application testing use the PageObjectModel framework. Makes things organized and not littered with findElements and locators, even if you do not use the CacheLookUp annotation.
I am not using Selenium RC or Remote WebDriver, but When I am trying to run my test , its throwing me error -
remotewebdriver.unpackAndThrowOnError(Response errorResponse)
My script has simple code:
driver.FindElement(By.XPath("xpath");
Error thrown at:
RemoreWebDriver.FindelementByXPath(String XPath);
Please help me resolving the issue
Because of the architecture of WebDriver, all discrete browser-specific drivers (FirefoxDriver, ChromeDriver, etc.), are subclasses of RemoteWebDriver. This means that, in keeping with good Object-oriented programming principles, the error handling code is common to all implementations, and is located in the base class, or RemoteWebDriver. This means that in the stack trace for any error, it’s common, even expected, to see RemoteWebDriver methods in the call stack.
Having said all of this, I suspect that the question you’re really asking is not, “Why do I see RemoteWebDriver in my stack trace when I’m not using remote?” Rather, I suspect the question you’re asking is, “Why is my FindElement call failing?” The answer to that depends on a lot of factors, but the most common is that the element isn’t located by the locator you’re specifying, or that the element isn’t actually in the page’s DOM when you attempt to find it. In the former case, you should fix the locator; in the latter case, you should wait for the element to be present before finding it (usually by using WebDriverWait, or a similar construct).
Of course, without the HTML you’re attempting to automate, and the full WebDriver code you’re attempting to use, more detailed advice is impossible to provide.
I am using "org.openqa.selenium.phantomjs.PhantomJsDriver" Java class.
At times, I need to identify whether a given WebElement is a particular type of web element; eg: Is this webelement a input type element or not.
This does not seem to come with PhantomJsDriver package.
"com.gargoylesoftware.htmlunit." package seems to have useful wrappers on top of web elements. I can write code like "element instanceof HtmlInput".
Question here is
- Can I really HTMLunit package with phantomjsdriver ? Am I using two libraries which are not supposed to be used with one-another ?
No. Unfortunately, you can't do this the way you're doing it. PhantomJsDriver is backed by WebKit, while HtmlUnitDriver is backed by HtmlUnit which has its own browser core. Selenium is able to wrap both these (and some more) under one hood, but we can't use them interchangeably.
There are, however, different ways of doing what you're trying to do, the best probably being using Selenium's own methods getTagName() and getAttribute() if needed.
If you ran getTagName() on your input element, it would gladly return "input".
I have been working on ATCs during 2 months and I continue having problems with Chrome, Selenium and JBehave. The Chrome driver for selenium has some bugs. For example: Sometimes it said that the components could not be found or clickable. For this situation, I used a workaround, but it is a little hugly.
When I run the ATCs, sometimes one of then fail due to chrome selenium driver bugs!. Also, I don't like the JBehave's Reports.
Could somebody advise me another option to create ATCs?
Thanks!!!
Sarang
Consider Selenide - it's specifically create to resolve all these timing/ajax/"element not found" poblems. Selenide is extremely simple to start with (much simpler than Thucydides) and can be used with any framework: Junit, TestNG, JBehave - you name it.
I like Thucydides to write ATCs:
http://thucydides-webtests.com/2011/09/23/hello-world/
It has a nice report, with screenshots ...
You can write tests with easyb, junit or jbehave.
But it use selenium engine too.