Here's a more robust solution. It's possible to have multiple web browser windows with the same title. In that case, I wouldn't want to close all windows with a given title, just the last window that opened. So, the last three lines in this script identify the numeric value associated with the last window that opened containing "DAVID" in the title, then uses the system command to close that window.
#!/usr/bin/perl use strict; use warnings; use WWW::Mechanize::Firefox; my $mech = WWW::Mechanize::Firefox->new(); $mech->get("http://david.abcc.ncifcrf.gov/summary.jsp"); $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("http://david.abcc.ncifcrf.gov/term2term.jsp?annot=52,9,79, +85,25,32,39,3,47,45,63,76¤tList=1"); my $var = `wmctrl -l | grep \"DAVID\" | tail -1 | cut -f1 -d\" \"`; chomp $var; system("wmctrl -i -c \"$var\"");
In reply to Re: WWW::Mechanize::Firefox -- how to close firefox browser window
by jbernest
in thread WWW::Mechanize::Firefox -- how to close firefox browser window
by jbernest
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |