Hot answers tagged

7

List cheeses = driver.findElements(By.className("cheese")); findElements() does not wait, but returns list of elements (located by locator). List is empty if nothing is found. http://docs.seleniumhq.org/docs/03_webdriver.jsp Also, Selenium elders very strongly advise to use only explicit waits (no implicit). And especially warn about mixing implicit and ...


6

I've tested using format http://user:pass@host and it works. So in Python (in setUp() of MyClass(unittest.TestCase) class) this should look like: self.base_url = "http://user:pass@host" In Java based on #34 at code.google, the following code should work as well: public void login(String username, String password){ WebDriver driver = getDriver(); ...


6

No. Do not just split your pageObject into pageObject2, 3, 4, etc. This goes for all programming - split your classes logically by function, not arbitrarily! Your page object should be the source of truth for that specific page. When you start trying to interact with your page, does it really make sense that you should search between MyForm.java and ...


6

For writing Selenium tests itself, none. Selenium does not use SQL. Now if the application under test uses SQL, maybe you need a bit of knowledge to setup test data for your tests. For basic SQL knowledge have a look at the free SQL course at Codecademy. This should probably be enough.


3

Short answer: Yes it is a bad practise, unless you have a very very very good reason, do not use implicit wait. This Stack Overflow answers really puts the difference in great detail. I once had someone on my team who thought it was a good idea, until I started researching why all our tests had such a long starting time. Somewhere in our setup the implicit ...


3

Quickly glanced over the properties and methods of IWebElement, doesn't look like they can set values. However, you can easily execute some javascript snippet to change HTML in your page. IWebDriver driver; IJavaScriptExecutor js = driver as IJavaScriptExecutor; js.ExecuteScript("document.getElementById("title").innerHTML = "New text!";"); You might need ...


3

This error means that you have forgotten to include a dependency in your project. It's been suggested on stackoverflow that the dependency you forgot might well be selenium-server-standalone-version.jar. Does adding that jar to your project help?


3

Some good Selenium tutorial for beginner/Intermediate/Advance are given below : 1 - ToolsQA 2 - Guru99


3

I think that you should create a page object class for each page of the site. If you have a single page site, you can create page widgets instead of page objects. The page widgets will correspond to components of the web page (example: footer, header, etc). When the number of your page object classes increases, you should create a base class that all page ...


3

Short answer to your question: Unfortunately, Selenium do not provide any built-in function for minimizing the browser window, there is only function for maximizing the window. But there are some work around for doing this. You want window to be out of sight, then you need to use this code. by using it browser window will be out of your sight and you will ...


3

With JavaScript you can check if a DOM element is in the viewport, see this question for example code: http://stackoverflow.com/questions/123999/how-to-tell-if-a-dom-element-is-visible-in-the-current-viewport Now if we add this isElementInViewport() JavaScript function to our application under test we can call it from Selenium with the JavaScriptExecutor ...


2

I think I can point you in the right direction for MS Word, at least. You can use the Office Interop Assemblies in C#. Here is an example from .Net Pearls: using System; using Microsoft.Office.Interop.Word; class Program { static void Main() { // Open a doc file. Application application = new Application(); Document document = ...


2

Webdriver is a browser manipulation API only and as such the ability to read office or PDF files is out of scope of its capabilities, but the office interop libraries will allow you to read data from office files in C#, and there will be similar libraries for reading PDF documents.


2

Yes, it most certainly does. Selenium can only address elements once they're loaded, but that loading (controls, ajax calls, ...) is depending on your connection (and browser). In fact, I had a perfectly working script with nice explicit waits for our test environment. But the execution on the production website went bad in places, because the ajax calls ...


2

Hey there's two issues here: A) you're calling ToString on an IWebElement. Try calling vele.Text instead of vele.ToString() instead. This will get you the text of the element rather than a taxi representation of the IWebElement. B) you're using an xpath selector, but you're telling Webdriver that you want to use css selector to locate the element. You can ...


2

Why use XPath in your CSS selector? Just try this (assuming your selector is correct for the page you want to test). WebElement vele = driver.findElement(By.cssSelector("#Result h2")); You need to get the text of the WebElement. What you're doing is converting the webElement object to its string representation. Use this method instead: ...


2

WebDriver cannot be used todo browser specific actions, it can only be used to drive the web-page. Although sending the keys CTRL-TAB might switch tabs WebDriver will still think you are in the previous window. Switching Tabs as you want is thus actually something different. Each tab is actually a window organised in a tab like look-and-feel. Thus you ...


2

Setting up Selenium tests to run on Safari browser is a fairly complex process. You need to install Safari Extensions Developer Certificate in your machine and also install selenium webdriver as an extension in Safari Browser. Also there are some stability issues with Safari browser automation & Selenium combination on Mac 10.9 OS and below. The ...


2

Create a string variable and use it (for example) as follows: string strMyXPath = "//*[@id='" + recordId + "_ACTION_COLUMN']/a[2]/span"; driver.FindElement(By.XPath(strMyXPath)).Click();


2

It is a good programming practice to type the variable to be the the least-specific subclass that you actually care about. That way, your code is more reusable. In your case, if you actually need to call methods on FirefoxDriver that aren't defined on Webdriver, you should type Some_Variable to be FirefoxDriver. If you don't need to do anything ...


2

If you are testing for a specific image at a specific resolution then you could either compare the image with the reference image or quicker calculate the MD5 of the image and compare it with the expected. Be sure and wait for the page to be loaded, including images, before validation.


2

Please use below xml file and from command prompt go to project location and run as "ant generateReport" (Should have ANT). Let me know if you have any questions. .xml file: <project name="TestAutomation" basedir="."> <property name="LIB" value="${basedir}/lib" /> <property name="BIN" value="${basedir}/bin" /> <path ...


2

Instead of downloading and using your own Selenium jars I would use Maven. Maven is used as a build tool and will download any dependencies you might need, like the latest version of Selenium. Steps: Download & Install Netbeans with JDK at http://www.oracle.com/technetwork/java/javase/downloads/index.html (Also install JUnit with the installer) ...


2

I really like the answer from the link Philip Beadle posted in a comment: It's a bad idea to test the core browser's behaviour as it's not your logic, i.e. you should not need to test that arrow keys work with options since that's something your browser implements. And some Protractor (JavaScript) examples how to handle the drop from the same ...


2

The syntax is cumbersome, but there are a couple things you can do. If you don't care about the message returned by the first keyword, you can use Run keyword and return status. This is perhaps the easiest solution, since the keyword will return either True or False. ${status}= Run keyword and return status ... Page should contain element ...


2

You will find the answer here: http://robotframework.org/Selenium2Library/doc/Selenium2Library.html For reference, in this case I would use the keyword "Get Element Attribute" and compare it against the expected result.


2

You can use the Selenium2Library Get Element Attribute keyword to get the style attribute: | | ${style}= | Get element attribute | id=check_style@style You can then either use a regular expression to find the background color attribute or do some additional parsing. The latter would be easier to do in python than with robot keywords. For example, if you ...


2

Webdriver is faster, as compared to RC Webdriver mimics much more closer to real-life interaction; as compared to RC WebDriver supports more languages WebDriver is more actively followed/supported now; RC is past details: http://www.guru99.com/introduction-webdriver-comparison-selenium-rc.html


2

Ask your developers to add a name (which does not need to be unique) to relevant elements. find_elements (Java may have different spelling) returns a LIST of elements. If you cannot have name, you can find by CSS class. Xpath is locator of last hope, too brittle and too slow.


2

Try using //li[@class='moreGenres']/span as an xpath For css, what you have - .moreGenres>span does work - so see if maybe you have that li in more than one place perhaps? or maybe make it a bit more specific such as li.moreGenres>span or ul>li.moreGenres>span or (better) ul.this_list>li.moreGenres>span It might also be ...



Only top voted, non community-wiki answers of a minimum length are eligible