primate2-blog
primate2-blog
Primate2 & WebDriver Test Automation
2 posts
A blog by the developers of Primate2, a web automation tool that simplifys and streamlines complexities of modern automation testing for the web. Check out http://primate2.com for more information.
Don't wanna be here? Send us removal request.
primate2-blog · 12 years ago
Text
Why do automation "engineers" use spreadsheets for their locators?
Doing some recruitment lately, I interviewed a whole pile of automation "engineers", which the recruitment agencies assured me were experts in Java and various web automation APIs. More than half of them were using the classic Page Object Model, and of these half I reckon about 60% of them told me they were using spreadsheets for the locators in their Page Object Model (which is cool, I've got no problem with it at all). Lets get this out the way then. WHHHHHHAAAAATTTTT!??!?? Why the hell would you do that? None of the candidates I spoke to were able to sufficiently justify their reason - a few tried to tell me that it was user friendly and a few others told me they were "forced" to use it as the business they worked with wanted them to do it that way. These aren't reasons. Why not just build a database and chuck a simple web page together? That solves, for me: 1. Possibly multiple versions of the spreadsheet. 2. User experience - allows simple validation checks on the selectors if we input via a simple web page. 3. Single source - databases make sense for automation in the page object model. So if your using a spreadsheet and I absolutely missed the point , please please please explain it to me. While I'm at it. Why do automation "engineers" tell interviewers that they built their own frameworks when in reality they are using something out of the box, like junit or testng? I love these frameworks, and recognising why and when it's appropriate to use them is important. But don't tell me you built something you didn't. Please.
0 notes
primate2-blog · 12 years ago
Text
WebDriver/Selenium Grid Setup for Mac & WIndows Step By Step
WebDriver/Selenium Grid Setup
There’s not many ‘good’, straight forward, step by step guides to setting up WebDriver with Selenium Grid out there.  I’ll have a crack at it.
Prerequisites:
1. Get Java 6 or 7 installed on your machine. Google has this one.  If you’re on a Windows machine, make sure that you restart your machine after you install it.
Getting the files we need in the place we need them.
1. Hit http://seleniumhq.org.  Go to the downloads page.  Download the latest Selenium Server (which used to be called Selenium RC Server).
If you’re on a Windows box, then do the next few steps, if you’re a legend and use a Mac/Linux then scroll down and pick up from that section.
Windows:
1. From the Start Menu launch a Run window and type ‘cmd’ then hit enter to launch a command prompt window.
2. Run the following command: ‘cd C:\Users\awesome-sauce\Documents & Settings\Downloads’ Note: Remember that I’m assuming that your drive letter is C and that you downloaded to the Downloads folder of the user awesome-sauce.  An easy way to get the direct link to the downloads folder is to ask your browser download dialog to show you the Selenium server jar file in Explorer, then copy the address from the address bar in Explorer and paste it into the command prompt Window.  For newbies to command line, ‘cd’ in the command means change directory.
3. So now we’re in the directory where we downloaded Selenium Server jar file and we have java installed.  Let’s fire up a hub.  In the command prompt window, run the following command:
‘java -jar selenium-server-standalone-2.31.0.jar -role hub -port 4444’
Note: ‘selenium-servier-standalone-2.31.0.jar’ was the name of the file I just downloaded.  If the version number changes or the file naming convention changes then you will obviously need to change the file name in here.  Right now the ‘-role’ option is unimportant.  The ‘-port’ option may be of some some interest if you know that you block that port or are using it for something else.  If you are, then pick a different port and pop if after the ‘-port’ option, replacing ‘4444’.  Simples.
4. Fire up a browser.  Something good.  If you only have Internet Explorer on your machine, take a minute and go do the internet a favour and download Chrome or Firefox.  We can wait for you ;-).
Once you’re in a real browser, hit the following address:
‘http://localhost:4444/grid/console’
Note: First assumption here is that localhost is defined for your machine.  If it’s not working there’s some troubleshooting bits at the bottom of the post.  The bit after the colon is the port number that the hub is running on, so if you changed the ‘-port’ option in your start up call then you should put the correct port value here.
If you see a blank page with a little message from Selenium in the top left then we’re cooking and are right on track.
5. Let’s register some browsers.  Open another command prompt.  Repeat step 2 to get us back that directory that we downloaded the Selenium server into.  Let’s start up a Firefox instance:
‘java -jar selenium-server-standalone-2.31.0.jar -role webdriver -hub http://localhost:4444/grid/register -port 1234 -browser browserName=firefox,maxInstances=5,Platform=WINDOWS,version=20’
Go ahead and run that.  Obviously don’t forget to adjust some of your settings if you changed the port and the like.  Now head back the browser window you opened.  Start patiently/frantically hitting the refresh button until you get some little cute Firefox icons come up on the screen.  They can take up to a minute to register, depending on your machines speed.
Mac:
1. From Finder, go to Applications/Utilities and open a new Terminal window.
2. Run the following command: ‘cd ~/Downloads’ Note: I’m assuming that you downloaded to the Downloads folder of the user.
3. So now we’re in the directory where we downloaded Selenium Server jar file and we have java installed.  Let’s fire up a hub.  In the command prompt window, run the following command:
‘java -jar selenium-server-standalone-2.31.0.jar -role hub -port 4444’
Note: ‘selenium-servier-standalone-2.31.0.jar’ was the name of the file I just downloaded.  If the version number changes or the file naming convention changes then you will obviously need to change the file name in here.  Right now the ‘-role’ option is unimportant.  The ‘-port’ option may be of some some interest if you know that you block that port or are using it for something else.  If you are, then pick a different port and pop if after the ‘-port’ option, replacing ‘4444’.  Simples.
4. Fire up a browser.  Something good.  If you only have Internet Explorer on your machine, take a minute and go do the internet a favour and download Chrome or Firefox.  We can wait for you ;-).
Once you’re in a real browser, hit the following address:
‘http://localhost:4444/grid/console’
Note: First assumption here is that localhost is defined for your machine.  If it’s not working there’s some troubleshooting bits at the bottom of the post.  The bit after the colon is the port number that the hub is running on, so if you changed the ‘-port’ option in your start up call then you should put the correct port value here.
If you see a blank page with a little message from Selenium in the top left then we’re cooking and are right on track.
5. Let’s register some browsers.  Open another command prompt.  Repeat step 2 to get us back that directory that we downloaded the Selenium server into.  Let’s start up a Firefox instance:
‘java -jar selenium-server-standalone-2.31.0.jar -role webdriver -hub http://localhost:4444/grid/register -port 1234 -browser browserName=firefox,maxInstances=5,Platform=MAC,version=20’
Go ahead and run that.  Obviously don’t forget to adjust some of your settings if you changed the port and the like.  Now head back the browser window you opened.  Start patiently/frantically hitting the refresh button until you get some little cute Firefox icons come up on the screen.  They can take up to a minute to register, depending on your machines speed.
That was easy right?  What about some extensions though?  It’s boring just running stuff on Firefox.  How about Internet Explorer:
‘java -jar selenium-server-standalone-2.31.0.jar -role webdriver -hub http://localhost:4444/grid/register -port 1234 -browser browserName=firefox,maxInstances=5,Platform=MAC,version=20’
Chrome:
You need to hit a download first for Chrome.  We need to get the third party Chrome Driver which allows us to interact with Chrome.  Get them from here:
https://code.google.com/p/chromedriver/downloads/list
Make sure they are extracted to the same directory as your selenium-server-standalone-2.31.0.jar file.
For Mac:
‘java -jar selenium-server-standalone-2.31.0.jar -role webdriver -hub http://localhost:4444/grid/register -port 1234 -browser browserName=chrome,maxInstances=5,Platform=MAC,version=20 -Dwebdriver.chrome.driver=chromedriver/chromedriver’
For Windows:
‘java -jar selenium-server-standalone-2.31.0.jar -role webdriver -hub http://localhost:4444/grid/register -port 1234 -browser browserName=chrome,maxInstances=5,Platform=WINDOWS,version=20 -Dwebdriver.chrome.driver=chromedriver/chromedriver.exe’
Internet Explorer:
You need to hit a download first for Internet Explorer.  We need to get the third party IE Driver which allows us to interact with IE.  Get them from here:
https://code.google.com/p/selenium/downloads/list
Make sure they are extracted to the same directory as your selenium-server-standalone-2.31.0.jar file.
‘java -jar selenium-server-standalone-2.31.0.jar -role webdriver -hub http://localhost:4444/grid/register -port 1234 -browser browserName=”internet explorer”,maxInstances=5,Platform=WINDOWS,version=7 -Dwebdriver.internetexplorer.driver=IEDriver.exe’
  Troubleshooting
Localhost is not resolving:
Open up your hosts file and ensure that you have line that looks like:
127.0.0.1 localhost
Browsers not registering to grid:
Make sure that you have the drivers in the right directories
0 notes