FindRow with text values inside span attributes - html-table

I am using Watin to find rows in a jQuery table. However, jQuery sets some of its text in a cell within a span class. Watin does not work in these cases.
WebBrowser.Current.Table("grid").FindRow("Liza", columnNum)
The above code works for:
<td>Liza</td>
but not for:
<td><span>Liza</span></td>
Any clue how I can tweak the Watin code to work with span classes?

You might want to try using the Text property to identify
WebBrowser.Current.Table("grid").FindRowInOwnTableRows(t => t.Text.Trim()== rowidentifier, columnNum);

I had some similar issues, my recommendation is to create a helper class that's available to all your specs and you add helper functions there, such as removeHtml, wait for async request, this kind of thing. a good starting point would be these methods http://www.dotnetperls.com/remove-html-tags
So on your tests you can do something like
// where .NoHTML() is a extension method in your helper class
WebBrowser.Current.Table("grid").FindRow(value.NoHTML(), columnNum)
This might not be the exact answer, but I hope it helps

Related

Create a Reusable method to Verify list elements by Selenium WebDriver

I am new to this site and don't know how things show up here. I was reading the post from below where String array is being used to ListwebElements.
Verify list elements by Selenium WebDriver
String[] expected = {"GRAM", "OUNCE", "POUND", "MILLIMETER", "TSP", "TBSP", "FLUID_OUNCE"};
I am trying to do something similar using String Array trying to get different buttons on a UI page. I want to make this method reusable by changing the "expected" list per test. Does anyone know how you would make this method Reusable?
In my case, "expected" list is different each time depending on a page.
I would suggest to use the custom annotation for reusing purpose. Please see the example here.
If you are using JUnit you can also use parameterized test

Test case automation

I am new to test automation and I need help of experts who can help me in proceeding with the current difficulties.
Currently there is a web browser application which is tested manually based on the test cases in an excel.
There is also an automation framework also which uses Selenium and uses WebDriver and runs on Google Chrome.
The test cases(in excel) used for manual are taken up and another set of test cases(in excel) are written which is nothing but the div elements and the action which the framework should do like click or find which the framework will understand.
1.First I need to manually find out each div id for all the elements and put it in excel which the framework understands.How can I avoid this?
2.Also a new version of the application has come in which all the div id for the elements differ.Hence its pain to note the div id again and put them in excel.
How can I write the test cases only once for each case even if the div changes?
Please help.
Follow a design pattern, e.g. Page Objects
If ids will be changed try to use css and xpath selectors that do not stick to ids. The main idea is to specify such selectors that allow tests to find elements on the page using knowledge by their parents, tag names, other attributes that won't change (class and so on).

QTP: Unable to use CSS & Index properties while trying to identify object

I'm trying to run the line of code below in my script, but I get an error saying that more than one object with these properties was found on the page.
Browser("browser").Page("page").WebElement("css:=.normalDayOfMonth").Click
So, I tried adding an index, as shown below:
Browser("browser").Page("page").WebElement("css:=.normalDayOfMonth", "index:=0").Click
But now it's not detecting any object at all. Could anyone help me out with this? Thanks!
Edit: For anyone else who comes across this, it turned out I was using QTP10 and as Motti pointed out below, CSS and Xpath support was only added in QTP11.
The support for using CSS and XPath to identify test objects was added in QTP11, in your comments you say that you're using QTP10 which would explain why you're facing problems...
What's probably happening is that QTP is ignoring css as an unrecognizd property so your description matches all elements and then when you add index:=0 it brings one of the invisible elements (e.g HEAD or HTML) which can't be clicked.
If all you're trying to do is match the className you can use QTP's class identification property ("class:=normalDayOfMonth").
BTW the Highlight function is an undocumented function similar to the object repository's highlight functionality and can be very useful in troubleshooting tests.

Using OR with Selenium.Click - is this possible?

There is an image and a link on this webpage. Clicking on either of them does the same job. I was wondering if there is an option of including OR in Selenium.Click. Something like:
Selenium.Click("image") OR Selenium.Click("link");
Selenium doesn't offer OR condition. If the requirement is to click on either of the locators depending on which one is available, then you can easily create a custom method
This is written in JAVA, you can change it to your programming language
public void ClickOnAvailableLocator(String locator1, String locator2)
{
if(selenium.isVisible(locator1)
selenium.Click(locator1);
else
selenium.Click(locator2);
}
No, if you need to test both routes I would suggest two tests.

dojo: how to i know all the extension points of a widget

Say for example that i have a grid (dojox.grid.DataGrid). I want to know all the extension points available on that grid.
When checked with the dojo api doc in events section of the grid i cant find the extension points, (say for example extension point onBeforeRow is not listed in that event section).
Thanks in advance.
pretty much every public method is an extension point, in that you can dojo.connect to it. The "on" pattern indicates an event pattern, and there's no formal declaration beyond the naming pattern AFAIK.