真正的无头网络浏览器(具有非无头能力)? [英] Truly headless web browser (with non-headless abilites)?

查看:120
本文介绍了真正的无头网络浏览器(具有非无头能力)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我面临的挑战是(大多数情况下)无头运行,但是能够在计算机的默认浏览器中启动无头浏览器的当前状态.

The challenge I'm tasked with is to run headless (most of the time) but have the ability to launch the current state of the headless browser in the default browser on the machine.

无头我的意思是没有打开浏览器窗口.因此,我将PhantomJS与waitr-webdriver一起运行.

By headless I mean no open browser windows. So I'm running PhantomJS in conjunction with waitr-webdriver.

在无头状态下,我正在填写多页表单.在表格末尾,我需要能够在本机浏览器中启动当前状态的页面/会话. 如何实现?

In the headless state I am completing a multi-page form. At the end of the form I need to be able to launch that page/session with current state in my native browser. How can this be accomplished?

想象一下这种情况:

 #1 open_page (Headless)
    @browser = Watir::Browser.new :phantomjs
    @browser.goto "www.somewebsite.com"

 #2 fill in form (Headless)
    field = @browser.text_field(:id => 'field')
    field.set 'somevalue' if field.exists?

 #3 click to next page (Headless)
    button = @browser.button(:id => 'submitButton').click 

 #4 fill in form (Headless)
    field = @browser.text_field(:id => 'field')
    field.set 'somevalue' if field.exists?

 #5 click to next page (Headless)
    button = @browser.button(:id => 'submitButton').click

 #6 results page (Open this page in my native browser)
    @browser.open  # {Pseudo-code}

#6不起作用.这是我需要您的建议/建议的地方.

#6 Is not working. This is where I need your advice/recommendation.

推荐答案

您需要打开另一个browesr(@ browser2),然后加载URL.请记住,它的环境与无头版本不会完全相同.

You would need to open a different browesr (@browser2) and then load the URL. Keep in mind this won't have the exact same environment as the headless version.

这篇关于真正的无头网络浏览器(具有非无头能力)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆