I am creating a program to automate whatsapp messages to some clients, but a notification appears on the screen, I would like to press always allow to advance in the process. Using Selenium with java.
I already tried using code to deactivate the pop-up notifications but it doesn't work, so I would like to accept the permission so that the notification does not appear, I want to change the permissions so that the popup notification does not appear.
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.interactions.Actions;
/**
*
* @author DiseñoVerde
*/
public class Abrir_con_Chrome {
public int enviarnumero(int numero) {
int num = numero;
System.setProperty("webdriver.chrome.driver", "C:\\Users\\DiseñoVerde\\OneDrive\\WhatsappDirect\\driver\\chromedriver.exe");
ChromeOptions options = new ChromeOptions();
Map<String, Object> prefs = new HashMap<String, Object>();
prefs.put("profile.default_content_setting_values.notifications", 2);
prefs.put("credentials_enable_service", false);
prefs.put("profile.password_manager_enabled", false);
prefs.put("profile.managed_default_content_settings.notifications", 1);
options.setExperimentalOption("prefs", prefs);
options.addArguments("start-maximized");
options.addArguments("disable-infobars");
options.addArguments("--disable-extensions");
options.addArguments("--disable-notifications");
WebDriver wd = new ChromeDriver(options);
Actions builder = new Actions(wd);
wd.get("https://wa.me/505" + num);
return 0;
}
}
I wait your answer thank you!