I am trying to develop a test for a website. Normally, it would go Main page, click search button to results page, Click first link to product page.
However, sometimes when loading the first page, you get a dialog popup that asks the user their location to display better content.
I'm relatively new to Selenium, but I've done a decent amount of research on this and can't seem to find the right answer. Maybe I just don't know exactly what to search for.
How can I do a conditional that says If the box pops up, click the first option, and then EITHER way, check content of the page that would normally come up?
Note that I DO know how to test for elements etc, I just don't understand how to do the conditional bit. Also, I export this to Perl after, if that makes any difference.
Thanks in advance!
EDIT: Here's the script as-is.
use strict;
use warnings;
use Time::HiRes qw(sleep);
use Test::WWW::Selenium;
use Test::More "no_plan";
use Test::Exception;
use TimePerf2;
my $time= TimePerf2->new(60,90,120);
my $sel = Test::WWW::Selenium->new( host => "my_lan_ip",
port => 4444,
browser => "*firefox",
browser_url => "https://www.website.com/" );
$time->startTime("ALL");
$sel->set_timeout_ok("120000");
if ( ! $sel->open_ok("https://www.website.com/") ) {print "Location: " . $sel->get_location() . "\n";}
elsif ( ! $sel->set_speed("1500") ) { }
elsif ( ! $sel->click_ok("id=btnSearch") ) {print "Location: " . $sel->get_location() . "\n";}
elsif ( ! $sel->wait_for_page_to_load_ok("120000") ) {}
elsif ( ! $sel->is_element_present_ok("css=div.azi_result") ) {print "Location: " . $sel->get_location() . "\n";}
elsif ( ! $sel->click_ok("css=p.description a") ) {print "Location: " . $sel->get_location() . "\n";}
elsif ( ! $sel->wait_for_page_to_load_ok("120000") ) {}
elsif ( !$time->endTime("ALL") ) { }
else { $time->getTimes(); }
$sel->stop();