I want to get a string in the picture below. It is inside of an alert, prompt or dialog. My code is written in Perl and I am using Selenium Webdriver to navigate through the page.
What I have achieved so far:
- finding the link with selenium and clicking on it
- waiting for the alert to appear
- get a string from the alert, but not the string in the text field
Code
my $copy_elem = wait_until {
$d->find_element_by_id('clipboard-link');
};
$copy_elem->click;
select undef, undef, undef, 8.00;
my $alert = wait_until {
$d->get_alert_text;
};
$alert output is "Copy Link"
So the text that I want is inside the alert's text field. With get_alert_text I only get the Alert string, but not the text field content. I searched the Web for answers and saw people using window handles to switch to the alert. I tried to look for similar functions in Selenium Webdriver's documentation:
CPAN Selenium Webdriver Docu with list of functions
I tried getting the window handles and load them into an array, but it does not get a second window handle for the alert. get_current_window_handle doesn't work either. I used phantomjs and chrome as browsers. As far as I know there is no driver.switchto().alert(); for perl.
