access browser local storage

269 views
Skip to first unread message

Sergio Freire

unread,
May 31, 2012, 8:06:14 AM5/31/12
to selenium-ruby
Hello,
how can I access, using selenium-webdriver, the browser's local
storage? It is not well documented.
I tried this but it does not work:

driver = Selenium::WebDriver.for :chrome
driver.local_storage.clear


=> NoMethodError: undefined method `local_storage' for
#<Selenium::WebDriver::Driver:0x7f082e6baf48 browser=:chrome>


And it's a recente Chrome. I also tried with firefox with no luck.


Regards,
Sergio Freire

Mike Schaufelberger

unread,
Jun 4, 2012, 11:40:46 AM6/4/12
to seleni...@googlegroups.com
How to add persistent memory storage to selenium RC using browser cookies & java script in Selenium HTML:

######## FIRST WE SET COOKIES TO THE BROWSER FROM A LOCAL HTML DOCUMENT ########
<tr>
       <td>open</td>
       <td>file:///C:/DataSuite.html</td>
       <td></td>
</tr>
<tr>
       <td>storeText</td>
       <td>//tr[3]/td[2]</td>
       <td>password</td>
</tr>

<tr>
       <td>storeText</td>
       <td>//tr[4]/td[2]</td>
       <td>login</td>
</tr>
<tr>
       <td>storeText</td>
       <td>//tr[14]/td[2]</td>
       <td>url</td>
</tr>
######## NEXT WE SET COOKIES TO THE BROWSER FROM THE STORED TEXT COMMANDS ########
<tr>
       <td>createCookie</td>
       <td>password=${password};</td>
       <td>setPasswordCookie</td>
</tr>

<tr>
       <td>createCookie</td>
       <td>login=${login};</td>
       <td>setLoginCookie</td>
</tr>
<tr>
       <td>createCookie</td>
       <td>url=${url};</td>
       <td>setUrlCookie</td>
</tr>
######## NOW WE GET THE COOKIES FROM THE BROWSER ########
<tr>
       <td>storeExpression</td>
       <td>javascript{selenium.getCookieByName('password');}</td>
       <td>getPasswordCookie</td>
</tr>

<tr>
       <td>storeExpression</td>
       <td>javascript{selenium.getCookieByName('login';);}</td>
       <td>getLoginCookie</td>
</tr>

<tr>
       <td>storeExpression</td>
       <td>javascript{selenium.getCookieByName('url');}</td>
       <td>getUrlCookie</td>
</tr>
######## FINALLY WE USE COOKIES IN SELENIUM COMMANDS AT ANY TIME DURRING TEST########
<tr>
       <td>open</td>
       <td>${getUrlCookie}</td>
       <td></td>
</tr>

<tr>
       <td>type</td>
       <td>${userName_textBox}</td>
       <td>${getLoginCookie}</td>
</tr>

<tr>
       <td>type</td>
       <td>${password_textBox}</td>
       <td>${getPasswordCookie}</td>
</tr>






--
You received this message because you are subscribed to the Google Groups "selenium-ruby" group.
To post to this group, send email to seleni...@googlegroups.com
To unsubscribe from this group, send email to selenium-rub...@googlegroups.com
For Selenium-Ruby project, visit http://seleniumhq.org/projects/ruby/
For Selenium related questions like Core, Server, and RC client in other language, please go to http://clearspace.openqa.org/community/selenium

Reply all
Reply to author
Forward
0 new messages