Thursday 5 February 2015

Selenium-VBA

Using Selenium-VBA automation developer can develop the selenium script using VBA code in Excel.
Once the user actions are recorded with Selenium-IDE, they can be converted(i.e. formated) in to a VBA script and placed in the Excel and executed.

Below are the steps to be performed.
i.  Installing 'SeleniumWrapperSetup-<<version>>.exe'.
ii. Installing the Selenium-VBA addon in Selenium IDE.
iii. Selecting 'SeleniumWrapper Type Library' reference.
iv. Recording the user interactions in Selenium IDE.
v. Converting the recorded user interactions in to Selenium-VBA script.
vi. Writing the Selenium-VBA code in Excel.
vii. Executing the Selenium-VBA script.

Prerequisites:
1. Microsoft office is installed on Windows OS.
2. Firefox browser is installed.
3. Selenium-IDE is installed in Firefox browser.
4. Chrome browser is installed, if the scripts need to be executed on chrome browser.

1. Open the "Microsoft Office Excel Worksheet".

2. Create the Macro.







 3. Open References.


4. Verify 'SeleniumWrapper Type Library' is displayed in references.

5. if  'SeleniumWrapper Type Library' is not displayed in references, then search for 'Selenium vba wrapper download'.


6. Download the 'SeleniumWrapperSetup-<<version>>.exe' file.


7. Install the 'SeleniumWrapperSetup'.
Click 'Run' button.
 Click 'Next' button.
 Accept the agreement.
 Click 'Next' button.

Click 'Install' button.

 Don't uncheck the check box and click on 'Finish' button.
 Click 'Install Now' button to install Selenium-VBA addon in Selenium IDE.
Click 'Restart' button.
Verify Selenium-VBA is installed in Firefox browser extensions.

8. Perform create/open macro in excel.
Now verify 'SeleniumWrapper Type Library' is displayed is displayed in  "Tools" --> "References" in Excel.


9. Record the user interactions using Selenium IDE.
Open Selenium IDE
 


perform some actions, user actions are recorded in selenium ide.

10. Convert the script to VBA.
Select 'Options' --> 'Format' --> 'VBA/Webdriver'.


11. Copy the Selenium VBA recorded script.

12. Paste the copied script in Sub.



13. Change the browser name to 'chrome'.

14. Execute the script.

Note: Before executing the script make sure 'SeleniumWrapper Type Library' is selected in "Tools" --> "References". 




References: 

Environment used for executing the above Selenium-VBA script:
OS: Windows 7
Browser: Chrome 39
Microsoft Office 2007
SeleniumWrapperSetup-1.0.17.exe

No comments:

Post a Comment