Handle custom tags using WebDriver

By Published:
Sometime while doing automation we have to identify the element which have custom tags like <g> <svg> etc. For this we normally use * that will identify all elements tags in case we have to identify only specified custom tag then we can use below example for this.


<svg height="600" width="910" xmlns:xlink="http://www.w3.org/1999/xlink"  
   id="svgcontent" overflow="visible" x="910" y="600" viewBox="0 0 910 600">
    <g style="pointer-events:all">
      <text fill="rgb(0,0,0)" font-family="Sans-Serif" font-size="13" id="80-155-126" 
        transform="rotate(-90, 168, 126)" y="126" x="168" style="pointer-
         events:inherit">A100A</text>
   </g>
  </svg>

Following Xpath will work here

By.xpath("//*[local-name()='svg']")

By.xpath("//*[local-name()='text']")


By.xpath("//*[local-name()='g']")


Close All Browsers Except OLD One QTP VB

By Published:
Hi All,
Some times we required that Only OLD open Browser Window( Only for IE) will remain Open and rest of all should be closed during QTP scripting. Here is the Function which will close all the open Browsers except OLD Open browser (Work only for Internet Explorer using QTP)


Public function fn_CloseAllBrowsersExceptOLD
      rem create Browser description object

         Set brwsr=Description.Create

         brwsr(“micclass”).value=”Browser”

         Set obj=Desktop.ChildObjects(brwsr)

          browserCount= obj.count

         Set obj=nothing

         If  browserCount >1  Then

         do

            Browser(“CreationTime:=1″).Close

            Set obj=Desktop.ChildObjects(brwsr)

            browserCount= obj.count

            Set obj=nothing

         loop  until  browserCount =1

        End If
End Function

call  fn_CloseAllBrowsersExceptOLD( )