private async void Button_Click_28(object sender, RoutedEventArgs e)
        {
            try
            {
                if (webDriver != null)
                {
                    await webDriver.Close();
                }
                var profileName = tbOpenProfileName.Text;
                var dir         = Path.Combine(tbOpenProfileDir.Text, profileName);
                await FirefoxProfilesWorker.CreateFirefoxProfile(dir, profileName);

                asyncFirefoxDriver = new AsyncFirefoxDriver(new FirefoxDriverConfig()
                                                            .SetProfileName(profileName)
                                                            .SetDoOpenBrowserDevTools()
                                                            );
                browsersToClose.Add(asyncFirefoxDriver);
                webDriver = new WebDriver(asyncFirefoxDriver);
                await webDriver.Open();

                AddInfo("BrowserDevTools opened");
            }
            catch (Exception ex)
            {
                AddInfo(ex.ToString());
            }
        }
        private void lbProfiles_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            var profileName = (lbProfiles.SelectedItem as Tuple <string, string>)?.Item1;

            tbMarionPort.Text = FirefoxProfilesWorker
                                .GetMarionettePort(profileName)
                                .ToString();
        }
Exemplo n.º 3
0
        private async Task <string> Make_ffDriver(string profileName = "default", bool doOpenSecondPort = true)
        {
            FirefoxProfilesWorker.OpenFirefoxProfile(profileName);

            ffDriver            = new AsyncFirefoxDriver(profileName);
            ffDriver.DoConnect2 = doOpenSecondPort;
            return(await ffDriver.Connect());
        }
        private void Button_Click_5(object sender, RoutedEventArgs e)
        {
            var profileName = (lbProfiles.SelectedItem as Tuple <string, string>)?.Item1;

            if (int.TryParse(tbMarionPort.Text, out int port))
            {
                FirefoxProfilesWorker.SetMarionettePort(profileName, port);
            }
        }
        ///**
        // * Shortcuts for accessing various debugger preferences.
        // */
        //var Prefs = new PrefsHelper("devtools.debugger", {
        //  chromeDebuggingHost: ["Char", "chrome-debugging-host"],
        //  chromeDebuggingPort: ["Int", "chrome-debugging-port"],
        //  chromeDebuggingWebSocket: ["Bool", "chrome-debugging-websocket"],
        //});

        private async void Button_Click(object sender, RoutedEventArgs e)
        {
            var debuggerPort = 9876;
            //var config = new DriverConfig().SetCommandLineArgumets(" --start-debugger-server " + debuggerPort);
            var config = new FirefoxDriverConfig()
                         .SetCommandLineArgumets("-start-debugger-server " + debuggerPort) //;
                         .SetUserPreferences(new Dictionary <string, string>
            {
                { "devtools.debugger.prompt-connection", "false" },
                { "devtools.debugger.remote-enabled", "true" },
                { "devtools.chrome.enabled", "true" },
                { "devtools.debugger.remote-port", debuggerPort.ToString() },
                { "devtools.debugger.chrome-debugging-port", debuggerPort.ToString() }
            });
            var path = config.UserDir;

            asyncFirefoxDriver = new AsyncFirefoxDriver(config);
            webDriver          = new WebDriver(asyncFirefoxDriver);

            await asyncFirefoxDriver.Connect();

            var devToolsPrefs = new Dictionary <string, string>
            {
                { "devtools.debugger.prompt-connection", "false" },
                { "devtools.debugger.remote-enabled", "true" },
                { "devtools.debugger.remote-port", "9876" },
                { "devtools.debugger.chrome-debugging-port", debuggerPort.ToString() }
            };
            var devToolsProfileDir = Path.Combine(path, CHROME_DEBUGGER_PROFILE_NAME);

            devToolsProfileName = CHROME_DEBUGGER_PROFILE_NAME + new Random().Next(1000).ToString();
            await FirefoxProfilesWorker.CreateFirefoxProfile(devToolsProfileDir, devToolsProfileName);

            FirefoxProfilesWorker.AddWriteUserPreferences(devToolsProfileDir, devToolsPrefs);


            var xulURI = DBG_XUL;
            var args   = new string[] {
                //"-no-remote",
                "-foreground",
                //"-profile", this._dbgProfilePath,
                "-chrome", xulURI
            };
            var argsStr        = string.Join(" ", args);
            var configDevTools = new FirefoxDriverConfig()
                                 .SetProfileName(devToolsProfileName);

            //.SetIsTempProfile()
            //.SetCommandLineArgumets(argsStr);

            asyncFirefoxDriver2 = new AsyncFirefoxDriver(configDevTools);
            webDriver2          = new WebDriver(asyncFirefoxDriver2);
            await asyncFirefoxDriver2.Connect();

            await asyncFirefoxDriver2.Navigation.GoToUrl(DBG_XUL);
        }
        private void Button_Click_6(object sender, RoutedEventArgs e)
        {
            var profileName = (lbProfiles.SelectedItem as Tuple <string, string>)?.Item1;

            if (!string.IsNullOrWhiteSpace(profileName))
            {
                tbProfilesData.Text = string.Join(Environment.NewLine,
                                                  FirefoxProfilesWorker.ReadUserPreferences(profileName));
            }
        }
        private void Firefox_Button_Click_9(object sender, RoutedEventArgs e)
        {
            var profile = lbFirefoxProfiles.SelectedItem as Tuple <string, string>;

            if (profile != null)
            {
                FirefoxProfilesWorker.RemoveProfile(profile.Item1);
                lbFirefoxProfiles.ItemsSource = FirefoxProfilesWorker.GetProfiles().Select(v => Tuple.Create(v.Key, v.Value));
            }
        }
 private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
 {
     webDriver?.CloseSync();
     webDriver2?.CloseSync();
     try
     {
         process?.CloseMainWindow();
     }
     catch { }
     try
     {
         process?.Close();
     }
     catch { }
     try
     {
         FirefoxProfilesWorker.RemoveProfile(devToolsProfileName);
     }
     catch { }
 }
        private async void Button_Click_28(object sender, RoutedEventArgs e)
        {
            if (webDriver != null)
            {
                await webDriver.Close();
            }
            var profileName = tbOpenProfileName.Text;
            var dir         = Path.Combine(tbOpenProfileDir.Text, profileName);
            await FirefoxProfilesWorker.CreateFirefoxProfile(dir, profileName);

            asyncFirefoxDriver = new AsyncFirefoxDriver(new FirefoxDriverConfig()
                                                        .SetProfileName(profileName)
                                                        .SetDoOpenBrowserDevTools()
                                                        //.SetIsMultiprocessFalse()
                                                        //.SetDoSetDebuggerRemoteEnabled()
                                                        );
            webDriver = new WebDriver(asyncFirefoxDriver);
            //await webDriver.Open();
            await webDriver.GoToUrl("https://www.google.com/");

            //await asyncFirefoxDriver.OpenBrowserDevTools();
        }
Exemplo n.º 10
0
        private void Button_Click_11(object sender, RoutedEventArgs e)
        {
            var profileName = (lbProfiles.SelectedItem as Tuple <string, string>)?.Item1;

            FirefoxProfilesWorker.OpenFirefoxProfileOffline(profileName);
        }
Exemplo n.º 11
0
        private void lbProfiles_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            var profileName = (lbProfiles.SelectedItem as Tuple <string, string>)?.Item1;

            FirefoxProfilesWorker.OpenFirefoxProfile(profileName);
        }
Exemplo n.º 12
0
 private void Button_Click_4(object sender, RoutedEventArgs e)
 {
     lbProfiles.ItemsSource = FirefoxProfilesWorker.GetProfiles().Select(v => Tuple.Create(v.Key, v.Value));
 }