Hello tuneroaster and weclome to the monastery!

incognito => 0 option has be proven to be currently broken as Corion said (he is the author an, yes! he will fix it ;) also in a very recent post by me: some doubts on my first steps with WWW::Mechanize::Chrome and remember Super Search is our friend!

> please elaborate

If the chrome browser was started without options atm incognito will be always be the mode. But if you start chrome with the option --remote-debugging-port=9222 or manually or in your perl program, then you'll be able to connect to an existing instance and to an existing tab. I was prepaering the following example that shows what I mean:

use strict; use warnings; use Log::Log4perl qw(:easy); use WWW::Mechanize::Chrome; Log::Log4perl->easy_init($ERROR); # Set priority of root logger to ER +ROR my $mech = connect_to_an_existing_tab(); unless ( $mech ){ my $chrome_exe = choose_chrome_executable(); start_new_instance( $chrome_exe ) } print "broswer started or connected succesfully, listening on remote-d +ebugging-port ". ${$mech->target()}{transport}{port}, " status ", ${$mech->target()}{transport}{is_connected} ? "connected" : + "not connected","\n"; sleep 3; # go from Monastery Gates to Super Search $mech->click ( { selector => '#titlebar-top tbody tr td.monktitleb +ar ul li:nth-child(16) a'} ); # the super search form $mech->form_number( 2 ); # titles containing text field $mech->field( 'HIT' => 'WWW::Mechanize::Chrome'); # not working: SUPPORT NEEDED HERE ;) # # $mech->untick( 're', 'S' ); # $mech->tick( 're', 'N' ); # submit $mech->click( { selector => '#id-3989 center table tbody tr td.main_co +ntent form p:nth-child(17) input[type=submit]'} ); # ATTENTION: autoclose was fixed recently: # if ( $WWW::Mechanize::Chrome::VERSION < 0.56){ print "Press ENTER to terminte ( autoclose => 0 fixed in version 0 +.56 of the module)".."\n"; <STDIN>; } sub choose_chrome_executable{ my( $chrome, $diagnosis ) = WWW::Mechanize::Chrome->find_executabl +e(); if ( $diagnosis ){ print "problem finding chrome executable: $diagnosis\n"; } print "Should I use ",( $chrome ? "[$chrome]" : "-NOT FOUND-" ), " + or another executable (put full path or leave blank for default)\n"; my $chrome_path = <STDIN>; chomp $chrome_path; $chrome_path = -e $chrome_path ? $chrome_path : $chrome; return $chrome_path; } sub connect_to_an_existing_tab{ print "I have to use an existing chrome tab by title( for example +PerlMonks )? leave it blank to open a new browser instance\n"; my $tab_title = <STDIN>; chomp $tab_title; if ( $tab_title ){ my $mech; { local $@; eval{ $mech = WWW::Mechanize::Chrome->new( mute_audio => 0, autoclose => 0, autodie => 0, incognito => 0, tab => qr/$tab_title/, ); }; if ( $@ ){ print "problem connecting to an already open tab in a +running instance of chrome:\n$@\n\n". "close your running chrome instance and anothe +r one will be started with right configuration\n". "Press ENTER to continue..\n"; <STDIN>; return 0; } return $mech; } } else { return 0 } } sub start_new_instance{ my $chrome_exe = shift; print "I'll now open https://www.perlmonks.org (will be in incogn +ito mode despite incognito => 0)\n"; my $url = 'https://www.perlmonks.org'; $mech = WWW::Mechanize::Chrome->new( mute_audio => 0, autoclose => 0, autodie => 0, incognito => 0, launch_exe => $chrome_exe, launch_arg => [ "--remote-debugging-port=9222" ] ); $mech->get( $url ); }

L*

There are no rules, there are no thumbs..
Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.

In reply to Re: WWW:Mechanize::Chrome incognito by Discipulus
in thread WWW:Mechanize::Chrome incognito by tunerooster

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.