Friday, May 24, 2019

[C#] TimeSpan

            //DateTime currentTime = DateTime.Now;
            //TimeSpan stepTime = currentTime.Subtract(_startTime);
            //TimeSpan elapsedTime = currentTime.Subtract(_globalStartTime);
            //_startTime = currentTime;
           
            ////TimeSpan span = new TimeSpan(;


            //timePrevious = DateTime.Now;
            //timeCurrent = DateTime.Now.AddDays(1);
            //timeSubtracted = timeCurrent.Subtract(timePrevious).TotalMinutes



Use below.

             Globals.txt2 = DateTime.Now.ToString("HH:mm:ss");
            Globals.time2 = Convert.ToDateTime(Globals.txt2);

            TimeSpan dt = Globals.time2.Subtract(Globals.time1);

            string ttt = Globals.txt1 + "  " + Globals.txt2 + " " + dt.Seconds.ToString();
            //MessageBox.Show(ttt);

            Globals.txt1 = Globals.txt2;
            Globals.time1 = Convert.ToDateTime(Globals.txt1);

Friday, April 26, 2019

Unable to delete file .... 'chromedriver.exe' is denied



Severity    Code    Description    Project    File    Line    Suppression State
Error        Unable to delete file "C:\...\bin\Debug\chromedriver.exe". Access to the path 'C:\...\bin\Debug\chromedriver.exe' is denied.    ProviderSearchSelenium           


U:\>taskkill /f /im chromedriver.exe
SUCCESS: The process "chromedriver.exe" with PID 17196 has been terminated.
SUCCESS: The process "chromedriver.exe" with PID 9896 has been terminated.
SUCCESS: The process "chromedriver.exe" with PID 7792 has been terminated.
SUCCESS: The process "chromedriver.exe" with PID 14248 has been terminated.
SUCCESS: The process "chromedriver.exe" with PID 13724 has been terminated.
SUCCESS: The process "chromedriver.exe" with PID 20664 has been terminated.
SUCCESS: The process "chromedriver.exe" with PID 22560 has been terminated.
SUCCESS: The process "chromedriver.exe" with PID 3844 has been terminated.
SUCCESS: The process "chromedriver.exe" with PID 10300 has been terminated.

U:\>taskkill /f /im geckodriver.exe
SUCCESS: The process "geckodriver.exe" with PID 8844 has been terminated.
SUCCESS: The process "geckodriver.exe" with PID 10672 has been terminated.
SUCCESS: The process "geckodriver.exe" with PID 23896 has been terminated.
SUCCESS: The process "geckodriver.exe" with PID 22200 has been terminated.
SUCCESS: The process "geckodriver.exe" with PID 5468 has been terminated.

Wednesday, March 27, 2019

[CodedUI] get current Url in codedUI

BrowserWindow browser = BrowserWindow.Launch();
//Some Code Here
Uri uri = browser.Uri;
string st = uri.ToString();

Friday, March 22, 2019

[CodedUI] Disable Run Test after Builds



Check if the Run Test After Builds button is clicked in Test-Test Settings.

Friday, March 15, 2019

[Windows] Disable the Internet Explorer Security Certificate


Disable the Internet Explorer Security Certificate

Open Internet Explorer and click on "Tools," or the gear icon. Click "Internet Options" and click on the "Advanced" tab. Navigate to the "Security" subheading and remove the check marks on both the “Check for publisher’s certificate revocation” and “check for server certificate revocation” options. Click "OK" and then click "Apply." You may have to restart your computer for the options to fully take effect. Reload the website you were attempting to visit.

Tuesday, March 12, 2019

[WINDOWS] Find path for filename




C:\WINDOWS\system32>for %i in (cmd.exe) do @echo %~$PATH:i
C:\Windows\System32\cmd.exe

C:\WINDOWS\system32>for %i in (notepad.exe) do @echo %~$PATH:i
C:\Windows\System32\notepad.exe

Friday, March 8, 2019

[Windows] How to make applications open on the correct monitor when using multiple monitors?





I tried this successfully:
  1. Open the program.
  2. Move it to the monitor on which you would like it to open by default.
  3. Hit the Windows key + Shift + Enter.
From now on, it should open each time on the monitor of your preference.

 If this doesn't work, try below:

Display settings - Multiple Displays - Make this my main display

[Windows] Windows+Shift+arrow keys you instantly jump it to another screen

press Windows+Shift+arrow keys you instantly jump it to another screen.

Friday, March 1, 2019

[EXCEL] ADD CHECKBOX

- ADD DEVELOPER TAB
  1. GO TO File>> Options >> Customize Ribon and Select Developer checkbox.
  2. Click Developer tab >> Insert >> checkbox.


Thursday, February 28, 2019

[SQL] UPDATE TABLE



SELECT *  FROM [Portal].[dbo].[ProviderUsers]
where Username like '%sptest5%'


Update [Portal].[dbo].[ProviderUsers]
SET AccessFailedCount =0,
    Lockout = 0
Where Username like '%sptest5%'


SELECT *  FROM [Portal].[dbo].[ProviderUsers]
where Username like '%sptest5%'

Friday, February 22, 2019

[SQL] ISNUMERIC CAST REPLACE

    select isnumeric('abc')
    0
    select isnumeric (100)
    1

    select cast(23.495 as int)
    23

    select cast(replace('1234534!!!','!!!','') as int)
    1234534


Wednesday, February 20, 2019

[SQL] SELECT ISNULL(NULL, 'TEST');



SELECT ISNULL(NULL, 'TEST');
TEST
SELECT ISNULL('HELLO', 'TEST');
HELLO

Return the specified value IF the expression is NULL, otherwise return the expression:

Tuesday, February 5, 2019

[SQL] Get column name from Table




select * from [DBName].Information_schema.columns
where table_name = 'final_outgoing_323'


[SQL] Having clause with Group By and Where




SELECT DEPARTMENTNAME, SUM(SALARY)
FROM DBO.EMPLOYEE
GROUP BY DEPARTMENTNAME
HAVING SUM(SALARY) > 100000
ORDER BY SUM(SALARY) DESC




SELECT DEPARTMENTNAME, SUM(SALARY)
FROM DBO.EMPLOYEE
WHERE DEPARTMENTNAME ='HR'
GROUP BY DEPARTMENTNAME



OR

SELECT DEPARTMENTNAME, SUM(SALARY)
FROM DBO.EMPLOYEE
GROUP BY DEPARTMENTNAME
HAVING DEPARTMENTNAME='HR'



- WHERE CLAUSE AND HAVING TOGETHERE:

SELECT DEPARTMENTNAME,S UM(SALARY)
FROM DBO.EMPLOYEE
WHERE GENDER ='M'
GROUP BY DEPARTMENTNAME
HAVING SUM(SALARY) > 50000
ORDER BY SUM(SALARY) DESC

Thursday, January 31, 2019

[CodedUI] MS batch file example to run Web Performance Test

@echo off


Rem ________________________________________________________________________________________________
Rem
Rem Select Windows Version
Rem
Rem ________________________________________________________________________________________________

rem MS Windows version 10.0.14393
rem set CURRENT_DATE=%date:~10,4%%date:~4,2%%date:~7,2%
rem MS Windows version 10.0.10586

 set CURRENT_DATE=%date:~6,4%%date:~0,2%%date:~3,2%

echo %CURRENT_DATE%

Rem ________________________________________________________________________________________________
Rem
Rem       Define Project Folders, the Exe file and Test result and logfile folders
Rem               TextExeFileProd = WebTestProd.webtest    - check Production sites only
Rem            TestExeFileAll  = WebTestAll.webtest     - check all sites including Test and Staging
Rem 
Rem ________________________________________________________________________________________________

set exeDir=C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE
set ProjDir=C:\TestProject

set TestExeFileProd=%ProjDir%\WebAndLoadTestProject1\WebTestProd.webtest
set TestExeFileAll=%ProjDir%\WebAndLoadTestProject1\WebTestAll.webtest

set TestResultDir=%ProjDir%\TestResults\

set TestLogDir=\WebTest\TestResults\%CURRENT_DATE%\

Echo Creating %TestLogDir%

IF NOT EXIST "%TestLogDir%" (mkdir "%TestLogDir%")

echo Project Folder= %ProjDir%


Rem ________________________________________________________________________________________________
Rem
Rem       Cleanup the subfolders in Test LOG Folder
Rem
Rem ________________________________________________________________________________________________

pushd %TestLogDir%

 FOR /D %%P IN ("*HQ*") DO ECHO DELETING "%%P" & IF EXIST "%%P" RD /S /Q "%%P"

Rem ________________________________________________________________________________________________
Rem
Rem        Cleanup Test Log Folder and delete existing files
Rem 
Rem ________________________________________________________________________________________________

Echo Cleaning up %TestLogDir%

IF EXIST "%TestLogDir%\*" ( DEL /Q "%TestLogDir%\*" )


Rem ________________________________________________________________________________________________
Rem
Rem       Execute Test for Prod and All and Create a TestResult Log file
Rem               TextExeFileProd = WebTestProd.webtest    - check Production sites only
Rem            TestExeFileAll  = WebTestAll.webtest     - check all sites including Test and Staging
Rem ________________________________________________________________________________________________

Echo Executing %TestExeFileProd%

 "%exeDir%"\MSTest.exe /testcontainer:"%TestExeFileProd%" /resultsfile:"%TestLogDir%\testResultsProd.trx" > "%TestLogDir%"\TestResultsProd_%CURRENT_DATE%.log

Echo Executing "%TestExeFileAll%"

 "%exeDir%"\MSTest.exe /testcontainer:"%TestExeFileAll%" /resultsfile:"%TestLogDir%\testResultsAll.trx" > "%TestLogDir%"\TestResultsAll_%CURRENT_DATE%.log


Rem ________________________________________________________________________________________________
Rem
Rem     Move the Test Result file to Test LOG FOLDER
Rem
Rem ________________________________________________________________________________________________

Echo Moving Test Result file to %TestLodDir%

pushd  %TestLogDir%

FOR /R "%TestLogDir%" %%X IN (WebTestProd.webtestResult) do (IF EXIST "%%X" ECHO "%%X" & IF EXIST "%%X" copy "%%X" "%TestLogDir%\")

FOR /R "%TestLogDir%" %%X IN (WebTestAll.webtestResult) do (IF EXIST "%%X" ECHO "%%X" & IF EXIST "%%X" copy "%%X" "%TestLogDir%\")


Rem ________________________________________________________________________________________________
Rem
Rem       Cleanup the subfolders in Test LOG Folder again
Rem
Rem ________________________________________________________________________________________________

pushd %TestLogDir%

 FOR /D %%P IN ("*HQ*") DO ECHO DELETING "%%P" & IF EXIST "%%P" RD /S /Q "%%P"


Rem ________________________________________________________________________________________________
Rem
Rem     Run the powershell script to send an email
Rem
Rem ________________________________________________________________________________________________

Powershell.exe -executionpolicy remotesigned -File  SendEmailWebTestResult.ps1


popd


















[DOS] Call more than one command in For Loop



Add '&'

here is an example:

FOR /D %%P IN ("*HQ*") DO ECHO DELETING "%%P" & PAUSE & IF EXIST "%%P" RD /S /Q "%%P"

Monday, January 28, 2019

Friday, January 25, 2019

[Visual Studio] How to actually search all files in Visual Studio






I think you are talking about ctrl + shift + F, by default it should be on "look in: entire solution" and there you go.


Thursday, January 17, 2019

[SSMS] Cannot insert explicit value for identity column in table when IDENTITY_INSERT is set to OFF



Server: Msg 544, Level 16, State 1, Line 1 Cannot insert explicit value for identity column in table when IDENTITY_INSERT is set to OFF. 



 
SET IDENTITY_INSERT [AllAppsUITest].[dbo].[TestEnvironment] ON


Then Insert

 
/* Turn Identity Insert ON so records can be inserted in the Identity Column  */
SET IDENTITY_INSERT [dbo].[TableName] ON
GO
INSERT INTO [dbo].[TableName] ( [ID], [Name] )
VALUES ( 2, 'InsertName')
GO
/* Turn Identity Insert OFF  */
SET IDENTITY_INSERT [dbo].[TableName] OFF
GO

[Excel] Scroll Locked - Arrow Key not moving




Turning off scroll lock without the keyboard key

Windows 10 users
  1. Press the Windows key.
  2. Type on-screen keyboard and press Enter.
  3. When the on-screen keyboard appears, click the ScrLk button.

Tuesday, January 15, 2019

[MS Word] Font Size




Calibri 
Font size 11
Font size 14
Font size 18
Font size 24
Font size 36
Font size 48
Font size 72