Installing chromedriver to run with selenium webdriver on mac

Struggled a bit to have this up and running, so here are some notes!

1. Download chromedriver from here

2 Unzip it

3. Drag it to /usr/bin ( to locate /usr/bin : go to finder, from the go menu go to folder )

You may need to right click on the chrome driver and open it, this is because sometimes on Mavericks if the app is unsigned it doesn’t execute, so you will have to specifically run it.  *

 

4. Restart your system (don’t ask me why 🙂 )

5. Update your properties file to request your webdriver to chrome

*Running an unassigned app on mac

  • To override your security settings and open the app anyway:

    1. In the Finder, locate the app you want to open.

      Don’t use Launchpad to do this. Launchpad doesn’t allow you to access the shortcut menu.

    2. Press the Control key, then click the app icon, then choose Open from the shortcut menu.

    3. Click Open.

CSS selectors and selenium (webdriver)

When I started automation with selenium, I started using xpath, because that was the way to go. Till, when I moved companies, there was this talk of other QA engineers relying on CSS for locating elements from the DOM. I have recently started using CSS locators for various reasons. You can read about it here

I have been basing a lot of my locators on these very cool links

1. Are you ready to use CSS with selenium?
2. Multiple classes and ID’s, CSS- trips and tricks.
3. CSS selectors demystified from Sauceio 
4. Multiple classes and CSS by Maxdesign
5. Can I use this ?  Search
6. Css Rosetta stone and cookbook.
7. And my favorite of all, convert your Xpath to CSS using this link here.[cssify]

Some examples:-

  1. Spaces in classnames: So if you have a class name like this ul class=”A B”, you can do a ul.A.B
  2. Lists can be tricky: Here’s a pointer:
	<li class="shrUPGrid">
           <ul id="sfly_5" class=" shrSG shrSGSelect">
<ul>
	<li style="background-image: <span class=;">url(https://sphotos-a.xx.fbcdn.net.jpg)"></li>
</ul>
<ul>
	<li style="background-image: <span class=;">url(https://sphotos-a.xx.fbcdn.net.jpg)"></li>
</ul>

You can find the Li by

 findElement(By.cssSelector("li.shrUPGrid > ul > li:nth-of-type(""
							+ pictureIndex + ")")).click(); 

where pictureindex is the index of the li

If I am sounding all cryptic please don’t hesitate to drop me a line.