Methods Supporting Seleneium-Webdriver / Ruby - ruby

After hands on Selenium-Client and Watir I have started working on Selenium-Webdriver / Ruby.
However I am not getting any information of the Methods and frequently I am getting stuck in my scripts. Like setting an option in drop down is one of the example. I am not able to get all the elements of webpage.
Frequently I am getting errors like method not found
Can any one help me out by providing the updated list of methods for Selenium-Webdriver with Ruby.
I tried to find relevant information on Net and Forums. This URL contains the Methods however they are also giving the same Error.

I am using selenium webdriver for Automation with Ruby. A very good website is this with lots of info, especially on the use of Excel (automation) together with Ruby. I'm afraid you have chosen the hard way as C# & Java have lots of info and Ruby you need to scavenge the net as resources are limited. Stack overflow has lots of nice examples as well and as Kevin mentioned; it is much easier when you search for a specific error. If I was you I will download a very useful Firefox add-on called Firebug which can be used in conjunction with Selenium IDE. These 2 are very powerful tools that will help tackle most of the things you are getting stuck, at least web-page wise.
Firebug you can use it to inspect any element in a web-page (just right click) and then you can instruct the webdriver to find it via id, link, css or xpath. Xpath is the best when there is no id or css tag. Alternatively what I do when I really get stuck; is to fire up Selenium IDE (record & play) and record the action I want (i.e. choose a value from a drop down menu). Then I export the file into a Ruby script grabbing -only- the code that I need (xpath usually) from there.
Hope that helped. Please post any specific error that is still giving you a hard time and we can take it from there. After you download Firebug, right click the drop box that you want to select and post here the results of the inspect element function. Then I can possibly be of further help on how to select it properly.
Just to give you an idea the xpath should look something like the line below..:
element = driver.find_element(:xpath, "//input[#name='payment']")
Input is the name of the tag obviously . Then you can locate your element by its internal attributes like..: value, name or even type. The above line will put the result of this 'element' search into the variable element. You can miss the 'element =' bit if you are not interested in assigning a variable. However after you find everything you need to locate elements you will realise that you will also need (especially if you are working on automation) a way to control your error handling as web-driver will time-out or crash when it cannot locate an element that has not been already loaded.

I couldn't even tell if anyone's pointed to this documentation yet?
http://selenium.googlecode.com/svn/trunk/docs/api/rb/index.html

Related

Where is the firefox title located in the source?

This may seem like an odd question, but does anybody know where or how to locate the title in the firefox source code? like firefox.exe and the default home page source and such?
Google yielded no results, same as on the firefox page.
Looking for it manually would take a while, considering the sheer size.
The latest source code for Mozilla Firefox is nicely indexed on DXR in a searchable form (you can even use regular expressions there!).

where can I download this code

I find a interesting website:http://www.brightpointinc.com/interactive/political_influence/
I want to learn its visualization using d3.
But when I download it, using right click button-------- save as The download page seems does not work. It seems lack some data, so I get back to the website to download some data, but it lacks some of them, can anyone send me an work version? thanks
As Lars says, your best bet is to look at the source code. To do this, you can use something like Chrome Developer Tools or Firebug for Firefox. I use the latter, so I'll take that as an example.
First, I'd right-click on the visualization itself, and click on Inspect Element with Firebug. This will pull up the HTML, which is only semi-helpful, since it only shows the output rather than the JavaScript code which created it.
To get at the JavaScript, you can use Firebug's Script tab. Most websites have more than one script, so you can hunt through the scripts being used by browsing through the dropdown menu in the second toolbar. The _buildChords.js script looks the most promising; that has some recognizable d3 code in it. You could check out the others to see what else they're calling (since it looks like there might be others - data.js, events.js, and so on).
Happy learning.

In order to add new functionality to existing Firefox clients, do I need to create an extension or a plugin?

More specifically, the idea is to allow the user to open Firefox, highlight a word on a web page, right click on it, and have an additional option that, when selected, calls c++ code that does something with the input string (must call C++ code, unfortunately), and displays a dialog box showing the result.
I'm still not sure if in order to implement this functionality I need to create a Firefox plugin or an extension. Can someone point me in the right direction?
Also, if someone can show me sample code in order to get me started that would be appreciated. (XPCOM, which I'm not even sure is what I should be using, seems a bit complicated for this seemingly simple project.)
You need a regular Firefox extension. It can add an item to the context menu, NPAPI plugins cannot do this. When it is clicked it can get the selected text and send it to your binary library. The best way to call functions in this library is js-ctypes, XPCOM is not required.

How to make a site-lookup addon for Firefox?

I'd like to create an addon for Firefox that would enable me to search a particular site by selecting text on one site and choosing to search another site by selecting that option in the context menu.
I already have an extension like that in my browser - the Wikipedia Lookup extension. Basically, I want the exact same functionality but which will send the search text to a different site.
I'm completely new to Firefox addons, so can somebody tell me what's involved in this? Or point me at a site with a list of instructions to do a plugin like this? I can see examples on how to make a Hello World kind of plugin but I can't see how to extend that example into what I need. Thanks.
Have you considered opening the Wikipedia extension source and modifying the pointer from wikipedia.com to the other search site? This is assuming you're using Windows Vista or higher. The source code should be located at:
C:\Users\YourUserName\AppData\Roaming\Mozilla\Firefox\Profiles\xxxxxxxx.default\extensions\something#wikipedia.com\chrome\content
You would then have to modify the source code inside to change the pointer, and the POST variables string to match that of the site you will be using.
I hope this at least points you in the general direction!
-Alex

Selenium RC : Button is not clicked but test passes

I have a script which enters some data in the page and click save button.
Here I used HTML component id for save button.
selenium.click("StudentID:saveData");
I even provided proper wait condition and also tried with X path locator.
The test passes. It doesn't throw any error message but the button is not clicked and the data is not getting updated.
Please let me know what might be the issue .
I had a similar problem and used a CSS selector instead. CSS selectors are much faster than Xpath (and in my experience work better in general, though Xpath is necessary for certain things).
If you are using Firefox, install the Firebug add-on; right-clicking on an element on the page will give you the option to copy CSS path. I've found that I often have to make some changes to it to get it working properly but it allows you to get to very deeply nested elements quickly.
The W3C has a good page on CSS selectors here.

Resources