Hello
I tried to click on the Pair / Cancel on that Alert and nothing happend, in other case I tried it with regular element and it is return the text but not the Cancel / Pair
// function to click on element in alert
public boolean clickInAlertElement(WebElement elem) {
try {
wait = new WebDriverWait(getDriver(), 5);
wait.until(ExpectedConditions.alertIsPresent());
elem.click();
return true;
} catch (Throwable t) {
return false;
}
}
Thank you, is it alert first of all? Second, the link said about what is the label of the buttons and than click according to the link but I need to get the message and test it and according to the text, to decide on what to click, how to do it
so it’s interest because it works even when I just clicked sometimes on cancel / pair not relate to the alert, it works
I pass to the function the button itself, but still no work.
so what is the way to know what is written in the alert? and according to the text, to select the options? because I didn’t succeded get the text from it
These thing working in other thread and the prints are working, just the clicking and the alert thing is not working ,
I first of all need to get the text, after getting the text from the alert if it contains BT I don’t want to connect, I cancel it, else I paired it, so I need to get the text in the alert first of all and than just click cancel or pair
// function to click on element in alert
public boolean clickInAlertElement(WebElement elem) {
try {
wait = new WebDriverWait(getDriver(), 5);
wait.until(ExpectedConditions.alertIsPresent());
return true;
} catch (Throwable t) {
return false;
}
}
elem.getText()
And than if text contains the Bluetooth I need so Pair, else, cancel
But I didn’t get the text and as far as I saw It is not in the element that you see at the picture above
I mentioned several times look for alert title and button names as for usual app elements. Find it locators. Once in your above code alert appeared get it title and button texts as usual you do with other elements.