October 21, 2024
Chicago 12, Melborne City, USA
C++

click allow cookies popup on firefox selenium c#


I want to click on allow option which is coming out from a pop up of a website ,I want to do on firefox to allow cookies:
Popup alert

i try this code but not work :

FirefoxDriverService cService = FirefoxDriverService.CreateDefaultService(".", "geckodriver.exe");
cService.HideCommandPromptWindow = true;
FirefoxOptions options = new FirefoxOptions();
options.AddArgument("ignore-certificate-errors");
options.AddArgument("--user-data-dir=" + FolderPathToStoreSession);

options.AddArgument("--disable-notifications");
options.AddArguments("Firefox.switches", "--disable-extensions");
//options.AddArguments ("profile.default_content_setting_values.cookies", "1");
options.SetPreference("network.cookie.cookieBehavior", "0");
options.SetPreference("profile.default_content_setting_values.cookies", "1");
          

also i try alert :

   var alert = driver_Ref.SwitchTo().Alert();
   
alert.Accept();

but not work, it seems to be this is not alert,
how to click allow in popup, or allow it automatically



You need to sign in to view this answers

Leave feedback about this

  • Quality
  • Price
  • Service

PROS

+
Add Field

CONS

+
Add Field
Choose Image
Choose Video