Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

Re: WWW::Mechanize::Firefox -- how to close firefox browser window

by jbernest (Novice)
on Apr 28, 2013 at 23:42 UTC ( #1031123=note: print w/ replies, xml ) Need Help??

in reply to WWW::Mechanize::Firefox -- how to close firefox browser window

I figured out a solution. I installed the "WMCTRL" package, a linux windows manager, using "sudo apt-get install wmctrl". Now I use the "wmctrl -c "title of window"" system command in my perl script to close only the browser window with that title. See the 2 new lines of code below.

#!/usr/bin/perl use strict; use warnings; use WWW::Mechanize::Firefox; my $mech = WWW::Mechanize::Firefox->new(); $mech->get(""); $mech->click({ xpath => ('//*[@href="Upload a Gene List or Population" +]', single => 1), synchronize => 0 }); $mech->form_name('frmManager'); $mech->set_fields( 'pasteBox' => "RRI1, YLR149C, FUN19, YBR285W, ALD3, CUE5, RTC3 +, AIM3, YDL199C, FMP45, AST2, GIP2, YKL091C, YKL133C, GLG2, SYM1, VHS3, YJR124C, MCH1, MHO1, I +KS1, RKM1, STF2, SAC1, ATG7, YAK1", 'Identifier' => "OFFICIAL_GENE_SYMBOL", ); $mech->click ({ xpath => ('//input[@name="rbUploadType" and @value="li +st"]', single => 1), synchronize => 0 }); $mech->click({xpath => ('//*[@value="Submit List"]', single => 1), syn +chronize => 0}); $mech->back; my $retries = 100; while ($retries-- and ! $mech->is_visible( xpath => '//*[@value="Funct +ional Annotation Clustering"]' )) { sleep 1; }; die "Timeout" unless $retries; $mech->click({xpath => ('//*[@value="Functional Annotation Clustering" +]', single => 1), synchronize => 0}); $mech->get(",9,79, +85,25,32,39,3,47,45,63,76&currentList=1"); my $title = 'DAVID: Database for Annotation, Visualization, and Integr +ated Discovery (Laboratory of Immunopathogenesis and Bioinformatics ( +LIB); National Institute of Allergies and Infectious Diseases (NIAID) +; Science Applications International Corporation (SAIC)'; system("wmctrl -c \"$title\"");

Comment on Re: WWW::Mechanize::Firefox -- how to close firefox browser window
Download Code

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1031123]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (8)
As of 2015-11-28 15:24 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (743 votes), past polls