简体   繁体   中英

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")

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM