Posts

Showing posts from November, 2022

File Upload in Selenium with C#

Image
The file upload is a simple process for transferring a file from a local computer to a website. This blog will demonstrate how to upload files to a website using Selenium and C#. In this section, I'll go over two methods for uploading files to a website. Method 1: The SendKeys() method is used in the first method. This SendKeys() method will assist in automatically entering text into the editable element. In this method, I'll pass the file location to be uploaded as a parameter to the SendKeys() method. The following code snippet shows how to upload a file in Selenium. The first three steps show how to launch a Chrome browser. Navigate to the URL in the fourth step. Then some waiting time was added. Finally, the file upload element was discovered, and the physical path of the image to upload was passed through the SendKeys method. private   void   UploadButton_Click ( object   sender ,  EventArgs   e ) {      // Download the same version of chromedriver      var  

Read Values from appsettings.json in ASP.NET Core

Image
The appsettings.json file in ASP.NET Core contains all application settings. This blog will show you how to get the values from appsettings.json The following is an example of appsettings.json configuration. I have added a Sample setting here. It has two settings: AppName and Auth.The Auth setting contains Username and Password. appsettings.json "AllowedHosts" :  "*" , "Sample" : {    "AppName" :  "SampleApp" ,    "Auth" : {      "Username" :  "Parker" ,      "Password" :  "$@M9l3"   } } There are several methods for obtaining appsettings values. Let's go through them one by one. Method 1: Here the IConfiguration is injected to the HomeController constructor. Then using the GetValue<T> method the setting values are collected. The values are retrieved using the key. HomeController.cs public   class   HomeController  :  Controller {      private   readonly   IC