🙂 İNSANLARIN EN HAYIRLISI INSANLARA FAYDALI OLANDIR 🙂

Ramazan HABER / C# RMOS / Chrome çalıştırma ve get isteği ile değerler gönderme

1-) C# RMOS - Açık olan chromede yan sekme olarak tab açma

 

public void acikOlanChromedeYanSekmeOlarakAcar()

        {

            try

            {

                Process process = new Process();

                process.StartInfo.FileName = @"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe";

                process.StartInfo.Arguments = "google.com";

             // process.StartInfo.Arguments = "google.com" + " --new-window"; // yeni chrome açar

             // process.StartInfo.Arguments = "google.com" + " --incognito"; // gizli sekme olarak açar

                process.Start();

            }

            catch (Exception ee)

            {

                Console.WriteLine(ee.ToString());

            }

        }

 

2-) C# RMOS - Chrome çalıştırma ve get isteği ile değerler gönderme

 

 string link = "http://localhost:54826/?Adi=\"" + txtAd.Text + "\"&Departman=\"" + txtDepartman.Text + "\"&KullaniciKodu=\"" + txtKullaniciKodu.Text + "\"&Otel=\"" + txtOtel.Text + "\"&Soyadi=\"" + txtSoyad.Text + "\"";

 

System.Diagnostics.Process.Start("CHROME.EXE", link);

 

 

3-) C# RMOS - Chrome selenium (chromeyi port ile açma ve veri gönderip cokie alma sessions)

 

using OpenQA.Selenium;

using OpenQA.Selenium.Chrome;

using System;

using System.Diagnostics;

using System.Windows.Forms;

 

namespace WindowsFormsApplication15

{

    public partial class Form1 : Form

    {

        public Form1()

        {

            InitializeComponent();

        }

 

        private void button1_Click(object sender, EventArgs e)

        {

            int port = 9015;

            StartChromeDriver(port);

            IWebDriver driver = new ChromeDriver();

            ChromeOptions options = new ChromeOptions();

            options.DebuggerAddress = "127.0.0.1:" + port;

            driver = new ChromeDriver(options);

            driver.Url = "http://hotelextranet.odeontours.com/";

        }

        public static void StartChromeDriver(int port)

        {

            try

            {

                Process p = new Process();

                ProcessStartInfo psi = new ProcessStartInfo(@"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe");

                string args = "--remote-debugging-port=" + port.ToString() + " --user-data-dir=remote-profile";

                psi.Arguments = args;

                psi.Verb = "runas";

                p.StartInfo = psi;

 

                p.Start();

 

            }

            catch (Exception ee)

            {

                Console.WriteLine(ee.ToString());

            }

        }

        private void button2_Click(object sender, EventArgs e)

        {

            IWebDriver driver = new ChromeDriver();

            ChromeOptions options = new ChromeOptions();

            options.DebuggerAddress = "127.0.0.1:" + 9015;

            driver = new ChromeDriver(options);

            driver.Url = "https://www.google.com.tr/";

            var cokies = driver.Manage().Cookies;

            foreach (var item in cokies.AllCookies)

            {

                Console.WriteLine(item.Name+"-"+item.Value);

            }

    driver.Quit();

        }}}

 

 

cmd ile çalıştırma aşağıdadir:

C:\Program Files (x86)\Google\Chrome\Application>chrome.exe -remote-debugging-port=9014 --user-data-dir="C:\Selenium\Chrome_Test_Profile"

 

 

 

 

 

 2021 Nisan 03 Cumartesi
 1,476