Can we automate graphs generated using canvas tag for test automation in selenium using python?I want to extract the data points plotted on the graph.
You can using ocular ,if your graph is not dynamically changing for every second.
Through selenium we cannot automate graphs.
You can refer to http://www.testautomationguru.com/selenium-webdriver-how-to-automate-charts-and-graphs-validation/
you can embed ocular along with selenium code
Related
I am working on winium for a new use case regarding desktop automation. The problem I face is to identify those elements which don't have a name, class name or automation ID. I am using Inspect.exe and UISpy to locate elements on the desktop.
I tried googling, but didn't find an answer to locate such elements.
How can I locate such elements?
There are two strategies to locale UI elements:
using names, class, IDs like you mentioned.
using visual recognition (based on component appearance and coordinates)
In the case of the second strategy, take a look at the following tools:
BotCity Framework
Sikuli
Using these tools you can navigate in the interface based on UI elements appearance:
I've been asked to use Selenium to write some tests for a website. Several of the pages have graphs on them that are generated by the "chart.js" library. The tests require me to:
Read the size of some of the data values in the chart
Click on certain bars on the chart.
Hover over certain bars and validate the tool tips
The trouble is the chart is implemented as a single HTML canvas element, so there is no DOM for the details of the chart that selenium can manipulate.
You won't be able to access the chart directly using Selenium because there is no DOM, as you noted. There may be a way to access chart data using JavascriptExecutor to run JS commands. I'm not familiar with chart.js but I have written automation against CANVAS elements. I got with dev and talked to them about what I needed access to and they gave me pointers on methods, etc. that I could call to get what I needed. I use the page object model so I ended up writing some Java functions that wrapped around the JS code that accessed the CANVAS.
I'm very new to Selenium. I want to write Selenium test cases for GWT widget. I can wirte test case for HTML elements since they have id, but i'm not able to do the same in GWT. I want to test widgets such as textboxes, images, listbox etc.
Can anyone help me?
Thanks in advance,
Gnik
Now I set debugId for the GWT widgets. Using that Id I can access the elements and test.
For eg. In UiBinder set id as <g:TextBox ui:field="textBox" debugId="userBox"
In the java code, textBox.ensureDebugId("userBox");
I can access these widgets in Selenium as follows,
selenium.type("gwt-debug-userBox", "testing");
I don't know if selenium is the right tool to test GWT Widgets, I think there are special tools for that.
With Selenium you can automate the browser. If GWT doesn't provide ids for its html elements there are various other ways to locate your elements. For example you can use xpath or css selectors. Just check the Selenium documentation.
But again, be careful about what you want to test. You don't want to test that GWT Widgets create a proper Web application, that is done already. You probably want to use a special GWT test tool where you test the java side of your widget.
Good evening,
I'm trying to set up a request spec with RSpec / Capybara for a page that contains a Flot graph. I have the page set up such that the user has to click on a marked element within the graph (tick/data point) to continue. Obviously the graph is generated with Javascript (flot).
Is there a way to get capybara/selenium to click on a specific x/y position with the chart div? I can measure it out in the development environment such that it should hit the datapoint in the test.
I have found ways to generate this click event with javascript:
$(document.elementFromPoint(x, y)).click();
But I don't think there is a way to get this to work in RSpec. I'm looking for something more like:
find(".overlay").click(top:10px; left:50px;) # click offset from the top and left of graph div
response.body.should have_selector(# stuff that should show up on the page)
Not sure if it makes any difference, but I prefer Selenium over webkit at the moment so that I can see what it is doing... will switch to webkit once tests are running.
Capybara should allow you to execute Javascript from within an example when the driver supports it, e.g.:
page.execute_script('$(document.elementFromPoint(10, 50)).click();')
With selenium can one run a test which check all images on a current page if they contain ALT attribute and report images not having it ?
Yes. The first thing you need to do is decide which selenium you want to use.
You can use Selenium IDE, where a test consists of an HTML table.
You can use Selenium RC, where you write a test in a programming language (eg. C#, Java, PHP, Ruby, etc).
The latter is a little more complex at first, but if you want real power, you will use that method.
Then, you'll need to learn how to find all the images on a page.
//img is a good XPath query to use. For Xpath details, see w3schools, and especially this page.
Then you'll want to find images with an alt attribute: //img[#alt]
One approach would be to count how many images there are, and subtract the number with alt attributes.
You can also do this in WebDriver (soon to be Selenium 2). The following example is for TestNG/Java but other client languages are available.
List<WebElement> images = driver.findElements(By.xpath("//img[not(#alt)]"));
assertEquals(images.size(), 0);
For more feedback you could also use something like the following to output details of the images without alt attributes:
for(WebElement image : images) {
System.out.println(image.getAttribute("src"));
}
We have a similar test but we grab the page's Html and parse out the images with a regular expression and then match on a second regular expression looking for the alt tag. I haven't done a speed test, but I think it might be faster than doing the Xpath route.