Saturday 19 April 2014

Handling Windows Dialogs Using Selenium Part4

This section describes some of the important API methods and their usage.


//The initial method to interact with a main window
public WindowElement getWindowElement(String windowName)
                     throws WindowsHandlerException


//To Check whether a particular window is present
public boolean isWindowPresent(String windowName) 


//To see whether an element is displayed on screen (Visible on screen)
public boolean isDisplayed(WindowElement element) 


//To determine whether an element is enabled to interact
public boolean isEnabled(WindowElement element)
                     throws WindowsHandlerException 


//To check whether an element is found
public boolean isNull(WindowElement element) 


//Retrieve Text Box Content
public String getTextBoxValue(WindowElement element)


//Get text of an Element
public String getText(WindowElement element)


//Search for Installed browser Version, Pass the Browser Enum as parameter
public String getInstalledBrowserVersion(Browser browser)
                     throws WindowsHandlerException 


//Start/Run/Open an application
public boolean openApplication(String appPath) 


//Close Process safely as a user would close it.
//Identify the process by id or multiple process by same name
//If the process cannot be closed in a natural way - kill the process
public void closeProcessesByName(String name, boolean forceKill)
public void closeProcessesByID(int pid, boolean forceKill)



//Search an element by following methods
public WindowElement findElementByAccessKey(WindowElement parentElement,
                     String accessKey) throws WindowsHandlerException


public WindowElement findElementByClassNameAndLocalizedControlType(
                     WindowElement parentElement, String className,
                     String localizedControlTypeName) throws WindowsHandlerException

public WindowElement findElementByAutomationID(WindowElement parentElement,
                     String automationID) throws WindowsHandlerException 

public WindowElement findElementByNameAndLocalizedControlType(
                     WindowElement parentElement, String name,
                     String localizedControlTypeName) throws WindowsHandlerException 

public WindowElement findElementByClassName(WindowElement parentElement,
                     String className) throws WindowsHandlerException

public WindowElement findElementByNameAndClassName(
                     WindowElement parentElement, String name, String className)
                     throws WindowsHandlerException


public WindowElement findElementByLocalizedControlType(
                     WindowElement parentElement, String localizedControlTypeName)
                     throws WindowsHandlerException

public WindowElement findElementByName(WindowElement parentElement,
                     String name) throws WindowsHandlerException 





Find Multiple Elements by
public List<WindowElement> findElementsByLocalizedControlType(
                     WindowElement parentElement, String localizedControlTypeName) 


To Be Contd..

59 comments:

  1. Your information about software testing is really interesting. Also I want to know the latest new techniques which are implemented in software testing. Can you update it in your website.

    ReplyDelete
  2. Thank you for the feedback :)

    #AT

    ReplyDelete
  3. Hi AT,

    Can i use regular expression for windowName in getWindowElement(String windowName)
    ex : getWindowElement("* - Windows Internet Explorer")

    Regards,
    Vinay

    ReplyDelete
    Replies
    1. Hello Vinay,

      Regular Expressions are not supported yet.

      #AT

      Delete
    2. Thanks for the reply, are there any plans in future?

      ~Vinay

      Delete
    3. please log your requests in the below page.

      https://docs.google.com/spreadsheet/ccc?key=0ArrZvkq9tkwPdEpfa0tFN0RIQ0ZyXy1mSGZPdzl4MVE&usp=drive_web#gid=5

      #AT

      Delete
  4. Hi AT,


    Through code i run the following :
    {{
    line1 : ffElement = handler.getWindowElement("Import Controls & Questionnaires - Mozilla Firefox");
    line2 : handler.setFocus(ieElement);
    line3 : WindowElement uploadElement = handler.findElementByName(ffElement ,"Choose File to Upload");
    line4 : WindowElement fileNamePath = handler.findElementByNameAndClassName(uploadElement, "File name:", "Edit");

    }}

    in the above code after line2 the dialog comes to the front at line3 i get the following error :
    {{
    [ATU Windows Handler Framework Exception] The Given Parent Element is null, Consider Checking the Parent Element's Identification parameters
    }}


    Using UISpy when i select "Set Focus" i get the following error :

    {{
    Exception
    Time Stamp:6/10/2014 8:01 PM
    Element:"window" "Import Controls & Questionnaires - Mozil..."
    Name:InvalidOperationException
    Message:Target element cannot receive focus.
    Stack Trace: at System.Windows.Automation.AutomationElement.SetFocus()
    at UISpy.Base.Node.SetFocus()

    }}

    though the element is present.

    Note : It is specific to one dialog, this code works fine on other dialogs. Not sure what attributes it is unable to find.


    Please let me know if you need any additional information using UISpy

    Appreciate your help.

    Regards,
    Vinay

    ReplyDelete
    Replies
    1. UISpy message indicates the element cannot receive focus. It is not necessary that UISpy must work on all the elements perhaps the developers of the Dialog may have restricted the element to be visible or the element is actually hidden and cannot receive focus - another element might be overlapping on this element (such as pane).

      #AT

      Delete
    2. Hi AT,

      Thanks for your kind reply.

      I tried to change the browser attributes and i was able to get the focus of all the elements in Upload Dialog box using UISpy, but when i run the java code i get the same error after executing line3 (code in my previous comments), if you notice line2 executes fine and the focus is set to the Browser.
      {{
      [ATU Windows Handler Framework Exception] The Given Parent Element is null, Consider Checking the Parent Element's Identification parameters
      }}

      Are there any specific attributes that handler.findElementByName looks for, if you could please tell me i will modify them and try again.

      Appreciate your help.

      Regards,
      Vinay

      Delete
    3. Vinay,

      "getWindowElement" is used to identify the main window (Parent window). In your code ""Import Controls & Questionnaires - Mozilla Firefox"" is this the name of the upload dialog ?

      If so, then first identify the Firefox browser main window using "getWindowElement", then try to find upload dialog.

      WindowHandler handler = new WindowHandler();
      WindowElement firefoxElement = handler
      .getWindowElement("Firefox Main Window name");
      WindowElement uploadDialog = handler.findElementByName(firefoxElement,
      "File Upload Dialog Name");

      #AT

      Delete
    4. Hi AT,

      I tried the same steps as you said, additionally i added another step to make sure the parent window is identified after
      -WindowElement firefoxElement = handler
      .getWindowElement("Firefox Main Window name");
      -handler.setFocus(firefoxElement );
      after executing this step the firefox window comes to the Front.
      and then after executing the below step the script fails with the exception Parent element is null
      -WindowElement uploadDialog = handler.findElementByName(firefoxElement,
      "File Upload Dialog Name");

      Regards,
      Vinay

      Delete
    5. Hi AT

      Thanks for your support, i just figured out the issue, it was caused because of special character '&' in the 'Name', i guess if you extend your support to accept special character it would be excellent.

      Regards,
      Vinay

      Delete
    6. Hi AT

      I have kind of question target element cannot receive focus but here am automating on excel using win32ole and RAutomation gem am using ruby and cucumber. Using win32 and msuia adapter for find the element here am attaching autoit window info
      >>>> Window <<<<
      Title:Book1 - Excel
      Class:XLMAIN
      Position:-9, -9
      Size:1938, 1050
      Style:0x17CF0000
      ExStyle:0x00010110
      Handle: 0x000908D4

      >>>> Control <<<<
      Class:ATL:66E99690
      Instance:6
      ClassnameNN:ATL:66E996906
      Name:Advanced (Class):[CLASS:ATL:66E99690; INSTANCE:6]
      ID:256
      Text:More>>
      Position:1656, 975
      Size:248, 20
      ControlClick Coords:30, 12
      Style: 0x56010000
      ExStyle:0x00000000
      Handle: 0x000C0

      Any workaround appreciated your help.

      Delete
  5. Thank you for sharing good information. I liked your blog, keep posting. I am from Indium software is an independent testing company that provides both Outsourced/In-house Manual & regression test automation testing services across the world. Testing & enhance the performance of your desktop, mobile or web application under load and stress.

    ReplyDelete
  6. I have the same problem
    [ATU Windows Handler Framework Exception] The Given Parent Element is null, Consider Checking the Parent Element's Identification parameters
    at atu.utils.windows.handler.WindowHandler.findElementByNameAndLocalizedControlType(WindowHandler.java:158)
    at com.seleniummaster.agent.ReportInfoCenter1.testTomcatAuthenticationInFirefox(ReportInfoCenter1.java:71)
    ...............................

    ReplyDelete
  7. we provide our valued clients a comprehensive portfolio of new age IT consulting services that streamline their process, help them manage change, innovate newer opportunities for maximizing profit and best of all assist build a credible brand.

    ReplyDelete
  8. very nice !!! i have to learning a lot of information for this sites...Sharing for wonderful information.
    CCNA training in chennai | CCNA training chennai | CCNA course in chennai | CCNA course chennai

    ReplyDelete
  9. Oracle Training in chennai
    Thanks for sharing such a great information..Its really nice and informative..

    ReplyDelete
  10. Really awesome blog. Your blog is really useful for me. Thanks for sharing this informative blog. Keep update your blog.
    Oracle Training In Chennai

    ReplyDelete
  11. very nice AT!!! Thanks for sharing such a nice information. Here i am stuck with an exception could you please help me out.
    Getting Error:
    [ATU Windows Handler Framework Exception] The Given Parent Element is null, Consider Checking the Parent Element's Identification parameters.

    Even though parent element is not null

    ReplyDelete
  12. Great discussion and inform on where is web design going in 2016. Each and every year web design is growing and plenty of innovative and impressive things are shared and published every day.design services

    ReplyDelete
  13. Thanks a lot AT!! ,your blog is awesome, has got very valuable information. I got know more about how to identify windows objects which i was searching from long time. It solved my automation problem..

    ReplyDelete
  14. Great efforts put it to find the list of articles useful for Selenium, Definitely will share the same to other forums.
    We are also one of the best sources to learn Selnium -Selenium training in Chennai | Best Selenium training institute in Chennai

    ReplyDelete
  15. Hi,
    Can anyone help me to handle WindowElements which has same attributes. That is both window elements are having same AutomationID and other attributes are also same.
    Appreciate your help.

    ReplyDelete
  16. Hello, I read your blog occasionally, and I own a similar one, and I was just wondering if you get a lot of spam remarks? If so how do you stop it, any plugin or anything you can advise? I get so much lately it’s driving me insane, so any assistance is very much appreciated.

    Devops Training in Chennai

    ReplyDelete
  17. Thanks for one marvelous posting! I enjoyed reading it; you are a great author. I will make sure to bookmark your blog and may come back someday. I want to encourage that you continue your great posts.
    Devops training in tambaram"

    Devops training in Sollonganallur"

    Deops training in annanagar"

    Devops training in chennai"

    Devops training in marathahalli"

    Devops training in rajajinagar"

    Devops training in BTM Layout"

    ReplyDelete
  18. I just needed to record a speedy word to express profound gratitude to you for those magnificent tips and clues you are appearing on this site.

    Software Testing Training in Chennai
    Software Testing Training
    QTP Training in Chennai
    Selenium Training in Chennai
    LoadRunner Training in Chennai

    ReplyDelete
  19. Thanks for your information, the blog which you have shared is useful to us.

    Education
    Technology

    ReplyDelete
  20. I simply wanted to write down a quick word to say thanks to you for those wonderful tips and hints you are showing on this site.
    python training in chennai
    java training in chennai

    ReplyDelete
  21. It is really wonderful and awesome thus it is very much useful for me to understand many concepts and helped me a lot. it is really explainable very well and i got more information from your blog.
    Java training in Chennai | Java training Institute in Chennai

    ReplyDelete
  22. Thanks for sharing this information, it helps me to learn new things. Continue sharing more like this.
    Data Science Training in chennai
    Data Science course in chennai

    ReplyDelete
  23. Its a wonderful post and very helpful, thanks for all this information.
    Vmware Training institute in Noida

    ReplyDelete
  24. Great Post,really it was very helpful for us.
    Thanks a lot for sharing!
    I found this blog to be very useful!!
    Software testing training in Bangalore

    ReplyDelete
  25. Thank you very much for this post I really appericate your efforts and if u want to know more about free background music kindly visit us

    ReplyDelete
  26. Langkah dimana para player hanya memberikan taruhan di permulaan permainan dan tidak perlu menjalankan tambahan chip lagi untuk permainan. Akan tapi pemain masih bermain dan menjalankan pemasangan taruhan di permainan tersebut.
    asikqq
    http://dewaqqq.club/
    http://sumoqq.today/
    interqq
    pionpoker
    bandar ceme terpercaya
    betgratis
    paito warna terlengkap
    syair sgp

    ReplyDelete

  27. Good Post! Thank you so much for sharing this pretty post, it was so good to read and useful to improve my knowledge as updated one, keep blogging.
    RPA using UI PATH Training in Electronic City

    ReplyDelete
  28. The information is worth thinking over. I am really thankful to you for posting this blog.
    Selenium Training in Chennai | Best Selenium Training in Chennai

    ReplyDelete
  29. What you have written has helped me a lot. I was thinking where to get such useful information. I will visit your website for more such informative blogs.
    Software Testing Training in Chennai | Software Testing Training Institute in Chennai

    ReplyDelete

  30. I believe there are many more pleasurable opportunities ahead for individuals that looked at your site.

    Top Angularjs Training in Chennai
    Top Java Training in Chennai
    Top Bigdata Hadoop Training in Chennai

    ReplyDelete
  31. Thanks for sharing such a great information..Its really nice and informative...
    Software Testing Course in Bangalore

    ReplyDelete
  32. INTELLIGENT SERVICE DESK - IMPROVING EMPLOYEE EXPERIENCE
    Service desks and self-service ticketing are ideal for the healthcare industry, and they have proven to be very successful. Healthcare institutions should implement automated platforms to maximize the benefits of healthcare for patients, doctors, and administrators.

    Learn More: Conversational AI service desk |

    ReplyDelete
  33. Thank you for sharing this valuable content. I truly appreciate reading such superb material with valuable insights. The presented ideas are excellent and quite intriguing, making the post thoroughly enjoyable. Please keep up the fantastic work.
    visit: Understanding Inheritance and Polymorphism in Java: A Comprehensive Guide


    ReplyDelete
  34. Thank you for providing this valuable content. I genuinely appreciate engaging with such exceptional material, enriched with valuable insights. The ideas presented are outstanding and thought-provoking, making the post exceptionally enjoyable. Please continue delivering such fantastic work.
    Also Read-Python for Data Science: A Comprehensive Guide

    ReplyDelete

  35. Thank you for sharing this invaluable content. I truly appreciate the opportunity to interact with such exceptional material, filled with valuable insights. The concepts presented are remarkable and stimulate deep thought, making the post exceptionally engaging. Please continue to provide such outstanding work; it is truly appreciated.
    Also Read: Quantum Query: A Data Analytics Quest

    ReplyDelete
  36. Excited to delve into Part 4 of Handling Windows Dialogs Using Selenium! Thank you for providing this valuable resource. Looking forward to gaining more insights and enhancing my skills in WebDriver automation.
    Also Read: Crafting Seamless Experiences with Full Stack Developer

    ReplyDelete