Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get form values in browser to watir webdriver

I have installed my application and it is running on following URL

http://localhost:3000

Above URL will the load form with some fields, Then I will the fill the data in the required field and then submit form. My div element will displayed at the bottom of the page. Picture will be displayed inside the iframe with in the div element.

User will the above URL and then submit form. After submitting the form, Picture should be downloaded into their local machine.

Right I am calling the following line after form submission, how can I get the existing page into the browser object and download screenshot?

browser = Watir::Browser.new
b.div(:id => "phone_shell").screenshot("/home/user/Documents/preview.png")
like image 884
Lakshmi Avatar asked Oct 29 '22 07:10

Lakshmi


1 Answers

I found few problems in your code

screenshot method is not available for element object, it's available for browser object and also you need to call the method save to save the file in the destination folder. So write the following code, it would work.

Code to get the html of the page

b.html

Code to take the screenshot

b.screenshot.save("/home/user/Documents/preview.png")

Now this will save the image in the destination folder.

like image 62
RAJ Avatar answered Nov 15 '22 05:11

RAJ