Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I pass Selenium WebDriver objects between seperate Ruby processes?

I want to pass an instance of an object between two Ruby processes. Specifically, I want to pass an instance of a Selenium WebDriver from one process to another process. The reason I want to do this is because it takes a lot of time for Ruby to create this object, but I want it to be used by the other process.

I've found some related questions here and here that seem to point towards using DRb, but I've been unable to find any useful examples or sample code.

Is there a tool other than DRb that I should be using? Does anyone have an example similar to this that I could copy from?

like image 209
Seanny123 Avatar asked Aug 09 '13 11:08

Seanny123


People also ask

Does Selenium support Ruby?

Yes. Selenium supports a wide range of programming languages including C#, Java, JavaScript, PHP, Python, and Ruby.

How many Webdrivers are there in selenium?

There are four basic components of WebDriver Architecture: Selenium Language Bindings. JSON Wire Protocol. Browser Drivers.

What are different types of methods in selenium?

Selenium WebDriver interface has many abstract methods like get(String url), quit(), close(), getWindowHandle(), getWindowHandles(), getTitle() etc. WebDriver has nested interfaces like Window , Navigation , Timeouts etc. These nested interfaces are used to perform operations like back(), forward() etc.

What is needed for development and testing of Ruby project with selenium?

In order to get started with Selenium with Ruby, you would need the following 3 main components installed in your system: Ruby. Selenium WebDriver gem. A Browser driver.


1 Answers

It looks like you're going to have to use DRb, although the documentation for it seems to be lacking. There is however an interesting article here. You might also want to consider purchasing The dRuby Book by Masatoshi Seki to get a better idea of how to do this effectively.

Another option to investigate if you are not looking at simultaneous access, but you just want to send the object from one process to another, is to serialize (that is, encode in a way that Ruby can read) the object with YAML (for a human readable file) or Marshall (for a binary encoded file) and send it using a pipe. This was mentioned in another answer that has since been deleted.

Note that either of these solutions require modifying the Selenium code heavily since the objects you want to manipulate neither support copying, nor simultaneous access natively.

like image 146
Seanny123 Avatar answered Sep 28 '22 14:09

Seanny123