Configure Hysteria on Ubuntu Server

Install or update to the latest version:

bash <(curl -fsSL https://get.hy2.sh/)

Remove Hysteria:

bash <(curl -fsSL https://get.hy2.sh/) --remove
nano /etc/hysteria/config.yaml
listen: :443 

acme:
  domains:
    - example.com    
  email: example@gmail.com 

auth:
  type: password
  password: password

quic:
  initStreamReceiveWindow: 8388608 
  maxStreamReceiveWindow: 8388608 
  initConnReceiveWindow: 20971520 
  maxConnReceiveWindow: 20971520 
  maxIdleTimeout: 30s 
  maxIncomingStreams: 1024 
  disablePathMTUDiscovery: false 

acl:
  inline: 
    - reject(geoip:ir)
  # geoip: GeoLite2-Country.mmdb 


disableUDP: false
udpIdleTimeout: 60s

+ Take a look at the differences between Hysteria 2 and Hysteria 1 at https://hysteria.network/docs/misc/2-vs-1/
+ Check out the quick server config guide at https://hysteria.network/docs/getting-started/Server/
+ Edit server config file at /etc/hysteria/config.yaml
+ Start your hysteria server with systemctl start hysteria-server.service
+ Configure hysteria start on system boot with systemctl enable hysteria-server.service

References
https://v2.hysteria.network/docs/getting-started/Installation/

Get and Set the value of an input element In Selenium using C#

Get the Value of an Input Element:

To retrieve the current value of an input element, you can use the GetAttribute method to fetch the “value” attribute. Here’s an example:

using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;

class Program
{
    static void Main(string[] args)
    {
        // Create a new instance of the Chrome driver
        IWebDriver driver = new ChromeDriver();

        // Navigate to your web page
        driver.Navigate().GoToUrl("your_website_url_here");

        // Find the input element by its ID (replace with your element's ID)
        IWebElement inputElement = driver.FindElement(By.Id("your_input_element_id"));

        // Get the current value of the input element
        string inputValue = inputElement.GetAttribute("value");

        // Print the value to the console
        Console.WriteLine("Current Value: " + inputValue);

        // Close the driver when done
        driver.Quit();
    }
}

Set the Value of an Input Element:

To set a new value to an input element, you can use the SendKeys method. Here’s an example:

using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;

class Program
{
    static void Main(string[] args)
    {
        // Create a new instance of the Chrome driver
        IWebDriver driver = new ChromeDriver();

        // Navigate to your web page
        driver.Navigate().GoToUrl("your_website_url_here");

        // Find the input element by its ID (replace with your element's ID)
        IWebElement inputElement = driver.FindElement(By.Id("your_input_element_id"));

        // Set a new value to the input element
        inputElement.SendKeys("New Value");

        // Close the driver when done
        driver.Quit();
    }
}

 

Send double-click event to a web element using Selenium in C#

using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using OpenQA.Selenium.Interactions;
using System;

class Program
{
    static void Main(string[] args)
    {
        // Create a new instance of the Chrome driver
        IWebDriver driver = new ChromeDriver();

        // Navigate to your web page
        driver.Navigate().GoToUrl("your_website_url_here");

        // Find the element you want to double-click (replace with your element locator)
        IWebElement elementToDoubleClick = driver.FindElement(By.Id("your_element_id_here"));

        // Create an Actions object
        Actions actions = new Actions(driver);

        // Double-click the element
        actions.DoubleClick(elementToDoubleClick).Build().Perform();

        // You can add additional actions or interactions here if needed

        // Close the driver when done
        driver.Quit();
    }
}

 

Find td Element inside a tr Element using Selenium in C#

using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;

class Program
{
    static void Main(string[] args)
    {
        // Create a new instance of the Chrome driver
        IWebDriver driver = new ChromeDriver();

        // Navigate to your web page
        driver.Navigate().GoToUrl("your_website_url_here");

        // Find the tr element by its class or other suitable attribute
        IWebElement trElement = driver.FindElement(By.ClassName("rgRow"));

        // Find the td element inside the tr element
        IWebElement tdElement = trElement.FindElement(By.TagName("td"));

        // You can now interact with the tdElement as needed
        // For example, to get its text:
        string tdText = tdElement.Text;

        // Close the driver when done
        driver.Quit();
    }
}

 

Clicking an element in Selenium WebDriver using C#

Clicking an element in Selenium WebDriver using C# is quite straightforward. Once you have located the element using any of the locator strategies (like ID, class name, XPath, etc.), you can use the Click method to perform a click action on that element.

Here’s a simple example to demonstrate how to find an HTML element by its XPath and then click it:

using System;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;

namespace MySeleniumApp
{
    class Program
    {
        static void Main(string[] args)
        {
            // Initialize the Chrome Driver
            using (IWebDriver driver = new ChromeDriver())
            {
                // Navigate to a website
                driver.Navigate().GoToUrl("https://www.example.com");

                // Find the element by its XPath
                IWebElement element = driver.FindElement(By.XPath("your_xpath_here"));

                // Click the element
                element.Click();

                // Optionally, wait for the action to complete or for the next element to be visible
                // Example: using WebDriverWait
                
                // Close the driver
                driver.Quit();
            }
        }
    }
}

You can also use other locator strategies like By.Id, By.ClassName, etc., to find the element you want to click.

Finding an element by XPath in Selenium WebDriver using C#

using System;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;

namespace MySeleniumApp
{
    class Program
    {
        static void Main(string[] args)
        {
            // Initialize the Chrome Driver
            using (IWebDriver driver = new ChromeDriver())
            {
                // Navigate to a website
                driver.Navigate().GoToUrl("https://www.example.com");

                // Find element by its XPath
                IWebElement element = driver.FindElement(By.XPath("your_xpath_here"));

                // Perform actions on the element (e.g., click, send keys, etc.)
                string elementText = element.Text;

                // Output the text of the element
                Console.WriteLine($"Element text is: {elementText}");

                // Close the driver
                driver.Quit();
            }
        }
    }
}

 

Find an Element by Class Name and Text in Selenium

In Selenium WebDriver with C#, if you want to find an element based on both its class name and the text it contains, you can use XPath or CSS selectors for more advanced matching. XPath allows you to traverse the HTML DOM and perform more complex queries to find elements.

Here’s an example that demonstrates how to find an element by its class name and text content:

using System;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;

namespace MySeleniumApp
{
    class Program
    {
        static void Main(string[] args)
        {
            // Initialize the Chrome Driver
            using (IWebDriver driver = new ChromeDriver())
            {
                // Navigate to a website
                driver.Navigate().GoToUrl("https://www.example.com");

                // Find element by its class name and text content using XPath
                IWebElement element = driver.FindElement(By.XPath("//*[contains(@class, 'element_class_name_here') and text()='element_text_here']"));

                // Perform actions on the element (e.g., click, send keys, etc.)
                // ... Your logic here ...

                // Close the driver
                driver.Quit();
            }
        }
    }
}

 

Find HTML Element by Class Name in Selenium

using System;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;

namespace MySeleniumApp
{
    class Program
    {
        static void Main(string[] args)
        {
            // Initialize the Chrome Driver
            using (IWebDriver driver = new ChromeDriver())
            {
                // Navigate to a website
                driver.Navigate().GoToUrl("https://www.example.com");

                // Find element by its class name
                IWebElement element = driver.FindElement(By.ClassName("element_class_name_here"));

                // Perform actions on the element (e.g., click, send keys, etc.)
                string elementText = element.Text;

                // Output the text of the element
                Console.WriteLine($"Element text is: {elementText}");

                // Close the driver
                driver.Quit();
            }
        }
    }
}