Truly headless web browser (with non-headless abilites)?

好久不见. 提交于 2019-12-14 04:00:22

问题


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.

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?

Imagine this scenario:

 #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 Is not working. This is where I need your advice/recommendation.


回答1:


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.



来源:https://stackoverflow.com/questions/23593396/truly-headless-web-browser-with-non-headless-abilites

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!