Hi Monks,

I am requesting all your wisdom and your skills ( normally just one or two skills not more :) ) please

I am trying to recover datas ( url's ) from my config file which is an excel file. Information's are in the first column of the sheet; For each data obtained, i would like to add the data, the URL in the adress bar of chrome to run with the browser.

Here is the code

#!/usr/bin/perl use strict; use warnings; use Test::More; #use Test::Time; use Selenium::Remote::Driver; use Selenium::Remote::WebElement; use Spreadsheet::Read; use Text::CSV_XS; my $driver = Selenium::Remote::Driver->new( 'remote_server_addr' => 'localhost', 'browser_name' => 'chrome', 'port' => '4444', ); my $excel = ReadData ("TEST.csv"); my $data = $excel->[1]{A1}; foreach my $data (0..9){ $driver->get($data); $driver->maximize_window(); #$driver->find_element('q','name')->send_keys($data); $driver->pause(2000); $driver->send_keys_to_active_element(KEYS->{'control'}, 't'); $driver->pause(2000); my $filename = "screenshot.png"; $driver->capture_screenshot($filename); $driver->pause(2000); } $driver->quit();
Here the output i get in my cmd
C:\Users\user1\Documents\TESTPERL>perl TEST6.pl Error while executing command: invalid argument: 'url' must be a strin +g (Session info: chrome=70.0.3538.77) (Driver info: chromedriver=2.43.600210 (68dcf5eebde37173d4027fa8635e +332711d2874a),platform=Windows NT 6.1.7601 SP1 x86_64) at C:/Strawber +ry/perl/sit e/lib/Selenium/Remote/Driver.pm line 391. at C:/Strawberry/perl/site/lib/Selenium/Remote/Driver.pm line 348.

What is going wrong please?

Is there an other (better) way to do it ? I know that TIMTOWTDI (Perl !!). I'm not sure, i am thinking about a hash or something like that but as i am a beginner i don't know how to do it exactly. Instead of having a simple loop and have to change the incrementation...

Thanks in advance


In reply to Recover Excel data from cells with Foreach loop by Perlchaoui

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.