Skip to main content

Posts

HTML Parsing and Selenium

HTML parsing is always been a burning requirement with selenium. Though Selenium doesn’t have built in API which could do HTML parsing, given its high integrability it could be integrated with HTMP parser to achieve the same. I have experimented on HTML parsing using Jericho which is java library. To begin HTML parsing the only demand Jericho makes is about HTML Source and this could be obtained using Selenium API - getHtmlSource(). Herein I have listed functions which I have developed using Jericho - Count number of tables on a page – // Get Source object for HTML Tables. Source source = new Source(selenium.getHtmlSource()); List table = source.getAllElements(HTMLElementName.TABLE); Reporter.log("Number of Tables are: " +table.size()); ***Reporter is TestNG API*** Retrieve Table Data- // Retrieve table data from a specific table.Source tableSource = new Source(table.get(3).toString()); Reporter.log("Table data is:" +HTMLTableParser.getTableData(tableS...

Retrieving dynanic HTML Objects from selenium

We often come across situations of dynamic html objects where in HTML id/name of a page is not constant and some time we don't even get to have any constant part if HTML identifier. Of late I came across a page which had lots of check boxes but no part oh HTML id/name was constant. To over come this we created custom functions for selenium using js evaluation capabilities of selenium. Function objectives are: ****** Retrieves all dropdown objects in a web page ****** Retrieves all multiline text box objects in a web page ****** Retrieves all radio button objects in a web page ****** Retrieves all check box objects in a web page ****** Retrieves all text box objects in a web page Depending on the availability of HTML id or name these functions would retrieve either HTML id or name. These methods are as following -

How selenium recorder compares with other tools?

I had chance to work on QTP and to sneak in to Test Complete in my Organization. I am bit depressed as to how irrationally QTP and Test Complete record web application and how much script one should tweak manually to make it compact. Let me cite example of Google Search for this. A selenium test for Google Search would be like this - selenium.open("http://www.google.com/"); selenium.type("q", "I love My Company"); selenium.click("btnG"); This certainly gives impression of app being opened, some thing being typed (though "q" might not be very clear here) and some button being clicked (again "bthG" is not very clear here) Same recorded test in QTP be as following - Browser("Google").Page("Google").WebEdit("q").Set "I Love My Company" Browser("Google").Page("Google").WebButton("google search").Click Google With Browser and Page objects embedded ev...

Conducting Test using Remote Agent.

SP Agent is the machine which is used to generate virtual user load. We have load test being carried in our project which is to be simulated from client environment This is to avoid the network delays as users of this app would be in client environment load should be simulated form client environment. (In fact we observed difference in response time as high as 10 sec when we compared two test run. One using offshore Agent and other using onsite Agent.) For this we got a machine in Client and we would connect to this machine through vpn. Hence this would be used as Agent while we would control execution of test from offshore. To be able to do this we got two ports 19200 and 19202 opened on this machine from client environment . Opening of these two ports got us going with performance test.

How to avoid think time / wait time from being accumulated in Custom Timers.

In Silk Performer custom Timers are used to generate response time around transactions. It is usually inserted in the script generated by SP recorder. In a typical script it looks as following - ========================================================== MeasureStart("1020_ RANK_PREFERENCE"); // Custom Timer - Start for Rank Prefpage WebUrl(" https://test-qa.test.edu/testtesting/images/arrow.png "); **** Few more functions*** ************************** **** Few more functions*** MeasureStop("1020_ RANK_PREFERENCE"); // Custom Timer - stop for Rank Pref page ========================================================== With the inclusion of Think Timer (wait time kept deliberately to simulate real user behaviour as a typical user waits on a page before performing any action) script would look as following - =========================================================== MeasureStart("1020_ RANK_PREFERENCE"); // Custom Timer - Start for Rank Pref p...

QTP vs Seleium vs Other tools

I had a chance to look at this comparison and do not agree with few claims. (Not because I am dedicated to selenium but since I have found few of these working my self.) They are just mentioned as mere Yes or No with out any associated reasoning. I have tried to contradict few of these claims below - Ability to identify objects using multiple parameters: Selenium does indeed support multiple ways for identifying object like - id, name, Xpath, css, dom etc. Ability to run multiple scripts consistantly in a Batch mode: This can be easily achieved using frameworks like JUnit, TestNG etc, Object Oriented Scripting Support: Selenium has a long list of supported client drivers and if Java, C# are not object oriented then which language is object oriented? Integration with External libraries: What are libraries like TestNG, Fest, Ant which I have integrated with Selenium for my test effort Object parametrization: Can be achieved using TestNG Integrated Data Driven Test framework...

Testing HTML object using DOM and selenium

DOM is w3c standard for navigating through the objects of a structured doc, Same can be used for exercising HTML/XML docs. In HTML, each element is referred as an object hence text box, dropdown, radio button etc are objects. These objects have properties (like max length in case of text box etc) and methods. Herein properties of objects can be collected in selenium through evaluation of java script and then these can be compared against expected values. For example one can collect max length and size properties of text box by evaluating java script through getEval function as following - selenium.getEval("var property = new Array(); property[0] = window.document.getElementsByName('empNumber')[0].maxLength;" + "property[1] = window.document.getElementsByName('empNumber')[0].size; property.toString();"); /**** I have explained evaluation of js in issue - 9211 ****/ Now individual properties can be collected in an string array as following - String[] T...