Ankit_Add

Saturday, September 10, 2016

Getting started with Android mobile OS development

The question is why Android OS?
Android OS is free to develop and has not  unnecessary    restrictions like Apple where you need  a Mac to develop  Apps. I like freedom that Android  provides.


What will you need?
A computer with at least 1 GB of physical Ram with Eclipse for Java installed. Also you should install the Android sdk:
Once done, you will find a new perspective in Eclipse
Android SDK for Eclipse

Ok, you now need to create a virtual image for a cell phone device.

Hopefully now you can start coding with Android. If only Google had made it more simpler to develop Android apps. 

Tuesday, January 26, 2016

Top 30 Selenium Interview Questions & Answers

1) What is Selenium and what is composed of?
Selenium is a suite of tools for automated web testing.  It is composed of
  • Selenium IDE (Integrated Development Environment) :  It is a tool for recording and playing back.  It is a firefox plugin
  • WebDriver and RC:  It provide the APIs for a variety of languages like Java, .NET, PHP, etc. With most of the browsers Webdriver and RC works.
  • Grid: With the help of Grid you can distribute tests on multiple machines so that test can be run parallel which helps in cutting down the time required for running in browser test suites
2) What is Selenium 2.0 ?
Web testing tools Selenium RC and WebDriver are consolidated in single tool in Selenium 2.0
3) How will you find an element using Selenium?
In Selenium every object or control in a web page is referred as an elements, there are different ways to find an element in a web page they are
  • ID
  • Name
  • Tag
  • Attribute
  • CSS
  • Linktext
  • PartialLink Text
  • Xpath etc
4) List out the test types that are supported by Selenium?
For web based application testing selenium can be used
The test types can be supported are
a)      Functional
b)      Regression
For post release validation with continuous integration automation tool could be used
a)      Jenkins
b)      Hudson
c)       Quick Build
d)      CruiseCont
5) Explain what is assertion in Selenium and what are the types of assertion?
Assertion is used as a  verification point. It verifies that the state of the application conforms to what is expected.  The types of assertion are “assert” , “verify” and “waifFor”.
SeleniumSuite
6) Mention what is the use of X-path?
X-Path is used to find the WebElement in web pages. It is also useful in identifying the dynamic elements.
7) Explain the difference between single and double slash in X-path?
Single slash ‘/ ’
  • Single slash ( / ) start selection from the document node
  • It allows you to create ‘absolute’ path expressions
Double Slash ‘// ’
  • Double slash ( // ) start selection matching anywhere in the document
  • It enables to create ‘relative’ path expressions
8) List out the technical challenges with Selenium?
Technical challenges with Selenium are
  • Selenium supports only web based applications
  • It does not support the Bitmap comparison
  • For any reporting related capabilities have to depend on third party tools
  • No vendor support for tool compared to commercial tools like HP UFT
  • As there is no object repository concept in Selenium, maintainability of objects becomes difficult
9) What is the difference between type keys and type commands ?
TypeKeys() will trigger JavaScript event in most of the cases whereas .type() won’t. Type key populates the value attribute using JavaScript whereas .typekeys() emulates like actual user typing
10) What is the difference between verify and assert commands?
Assert:  Assert allows to check whether an element is on the page or not. The test will stop on the step failed, if the asserted element is not available. In other words, the test will terminated at the point where check fails.
Verify: Verify command will check whether the element is on the page, if it is not then the test will carry on executing.  In verification, all the commands are going to run guaranteed even if any of test fails.
11) What is JUnit Annotations and what are different types of annotations which are useful ?
In JAVA a special form of syntactic meta-data can be added to Java source code, this is know as Annotations.  Variables, parameters, packages, methods and classes are annotated some of the JUnit annotations which can be useful are
  • Test
  • Before
  • After
  • Ignore
  • BeforeClass
  • AfterClass
  • RunWith
12) While using click command can you use screen coordinate? 
To click on specific part of element, you would need to use clickAT command.  ClickAt command accepts element locator and x, y co-ordinates as arguments-
clickAt (locator, cordString)
13)  What are the advantages of Selenium?
  • It supports C#, PHP, Java, Perl, Phython
  • It supports different OS like Windows, Linux and Mac OS
  • It has got powerful methods to locate elements (Xpath, DOM , CSS)
  • It has highly developer community supported by Google
14) Why testers should opt for Selenium and not QTP?
Selenium is more popular than QTP as
  • Selenium is an open source whereas QTP is a commercial tool
  • Selenium is used specially for testing web based applications while QTP can be used for testing client server application also
  • Selenium supports Firefox, IE, Opera, Safari  on operating systems like Windows, Mac, linux etc. however QTP is limited to Internet Explorer on Windows.
  • Selenium supports many programming languages like Ruby, Perl, Python whereas QTP supports only VB script
15) What are the four parameter you have to pass in Selenium?
Four parameters that you have to pass in Selenium are
  • Host
  • Port Number
  • Browser
  • URL
16) What is the difference between setSpeed() and sleep() methods?
Both will delay the speed of execution.
Thread.sleep () :  It will stop the current (java) thread for the specified period of time.  Its done only once
  • It takes a single argument in integer format
Ex: thread.sleep(2000)- It will wait for 2 seconds
  • It waits only once at the command given at sleep
SetSpeed () :  For specific amount of time it will stop the execution for every selenium command.

  • It takes a single argument in integer format
Ex: selenium.setSpeed(“2000”)- It will wait for 2 seconds
  • Runs each command  after setSpeed delay by the number of milliseconds mentioned in set Speed
This command is useful for  demonstration purpose or if you are using a slow web application
17) What is same origin policy? How you can avoid same origin policy?
The “Same Origin Policy” is introduced for security reason, and it ensures that content of your site will never be accessible by a script from another site.  As per the policy, any code loaded within the browser can only operate within that website’s domain.
To avoid “Same Origin Policy” proxy injection method is used, in proxy injection mode the Selenium Server acts as a client configured HTTP proxy , which sits between the browser and application under test and then masks the AUT under a fictional URL
18) What is heightened privileges browsers?
The purpose of heightened privileges is similar to Proxy Injection, allows websites to do something that are not commonly permitted.  The key difference is that the browsers are launced in a special mode called heightened privileges.  By using these browser mode, Selenium core can open the AUT directly and also read/write its content without passing the whole AUT through the Selenium RC server.
19) How you can use “submit” a form using Selenium ?
You can use “submit” method on element to submit form-
element.submit () ;
Alternatively you can use click method on the element which does form submission
20) What are the features of TestNG and list some of the functionality in TestNG which makes it more effective?
TestNG is a testing framework based on JUnit and NUnit to simplify a broad range of testing needs, from unit testing to integration testing. And the functionality which makes it efficient testing framework are
  • Support for annotations
  • Support for data-driven testing
  • Flexible test configuration
  • Ability to re-execute failed test cases
21) Mention what is the difference between Implicit wait and Explicit wait?
Implicit Wait: Sets a timeout for all successive Web Element searches. For the specified amount of time it will try looking for element again and again before throwing a NoSuchElementException.  It waits for elements to show up.
Explicit Wait :  It is a one-timer, used for a particular search.
22) Which attribute you should consider throughout the script in frame for “if no frame Id as well as no frame name”?
You can use…..driver.findElements(By.xpath(“//iframe”))….
This will return list of frames.
You will ned to  switch to each and every frame and search for locator which we want.
Then break the loop
23) Explain what is the difference between find elements () and find element () ?
find element ():
It finds the first element within the current page using the given “locating mechanism”.  It returns a single WebElement
findElements () : Using the given “locating mechanism” find all the elements within the current page.  It returns a list of web elements.
24) Explain what are the JUnits annotation linked with Selenium?
The JUnits annotation linked with Selenium are
  • @Before public void method() – It will perform the method () before each test, this method can prepare the test
  • @Test public void method() – Annotations @Test identifies that this method is a test method environment
  • @After public void method()- To execute a method before this annotation is used, test method must start with test@Before
25) Explain what is Datadriven framework and Keyword driven?
Datadriven framework:  In this framework, the test data is separated and kept outside the Test Scripts, while test case logic resides in Test Scripts.  Test data is read from the external files ( Excel Files) and are loaded into the variables inside the Test Script.  Variables are used for both for input values and for verification values.
Keyworddriven framework: The keyword driven frameworks requires the development of data tables and keywords, independent of the test automation.  In a keyword driven test, the functionality of the application under test is documented in a table as well as step by step instructions for each test.
26) Explain how you can login into any site if it’s showing any authentication popup for password and username?
Pass the username and password with url
  • Syntax-http://username:password@url
  • ex- http://creyate:tom@www.gmail.com
27) Explain how to assert text of webpage using selenium 2.0 ?
WebElement el = driver.findElement(By.id(“ElementID”))
//get test from element and stored in text variable
String text = el.getText();
//assert text from expected
Assert.assertEquals(“Element Text”, text);
28) Explain what is the difference between Borland Silk and Selenium?
                          Silk Test Tool                         Selenium Test Tool
  • Borland Silk test is not a free testing tool
  • Selenium is completely free test automation tool
  • Silk test supports only Internet Explorer and Firefox
  • Selenium supports many browsers like Internet Explorer, Firefox, Safari, Opera and so on
  • Silk test uses test scripting language
  • Selenium suite has the flexibility to use many languages like Java, Ruby,Perl and so on
  • Silk test can be used for client server applications
  • Selenium can be used for only web application
29) What is Object Repository ?
An object repository is an essential entity in any UI automations which allows a tester to store all object that will be used in the scripts in one or more centralized locations rather than scattered all over the test scripts.
30) Explain how Selenium Grid works?
Selenium Grid sent the tests to the hub. These tests are redirected to Selenium Webdriver, which launch the browser and run the test.  With entire test suite, it allows for running tests in parallel.

Sunday, January 17, 2016

WhatsApp now allows users to backup pictures, videos and chats to Google Drive

whatsapp-logo
A new update (2.12.304) on the WhatsApp app for android devices allows users to take backups on Google Drive.

So next time you lose or format your phone, you can easily get back pictures, videos and chats you shared with your friends on WhatsApp.




How to backup pictures, chats and videos on Google Drive in WhatsApp?

  1. After you open WhatsApp, go to Settings and select Chats and calls
  2. Select Chat backup option, here you can select the Backup to Google Drive option

whatsapp-google-drive-backup
WhatsApp backup on Google Drive

Note: If you don't have this option, then you don't have this update 2.12.304. You can still backup to your local phone storage for backups.

Wednesday, September 23, 2015

How to handle javascript alerts, confirmation and prompts?

Generally JavaScript popups are generated by web application and hence they can be easily controlled by the browser.
Webdriver offers the ability to cope with javascript alerts using Alerts APIClick here to view Alert API Details
// Get a handle to the open alert, prompt or confirmation
Alert alert = driver.switchTo().alert();
Alert is an interface. There below are the methods that are used
//Will Click on OK button.
alert.accept();
// Will click on Cancel button.
alert.dismiss()
//will get the text which is present on th Alert.
alert.getText();
//Will pass the text to the prompt popup
alert.sendkeys();
//Is used to Authenticate by passing the credentials
alert.authenticateUsing(Credentials credentials)

Working with Alerts using Selenium Webdriver:

The below is the sample code for alerts, please copy and make an html file and pass it to the webdriver.
<html>
<head>
<title>Selenium Easy Alerts Sample </title>
</head>
<body>
<h2>Alert Box Example</h2>
<fieldset>
<legend>Alert Box</legend><p>Click the button to display an alert box.</p>
<button onclick="alertFunction()">Click on me</button>
<script>
function alertFunction()
{
alert("I am an example for alert box!");
}
</script>
</fieldset>
</body>
</html>

The below program will demonstrate you working on Alerts popup using above html file.
import org.openqa.selenium.Alert;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.Test;

public class PopupsHandling {
 WebDriver driver=new FirefoxDriver();
 @Test
 public void ExampleForAlert() throws InterruptedException
 {
  driver.manage().window().maximize();
  driver.get("file:///C:/path/alerts.html");
  Thread.sleep(2000);
  driver.findElement(By.xpath("//button[@onclick='alertFunction()']")).click();
  Alert alert=driver.switchTo().alert();
  System.out.println(alert.getText());
  alert.accept();
 }
}

Working with Confirmation Popups

The below is the sample code for confirmation Popup, please copy and make an html file and pass it to the webdriver as below.
<html>
<head>
<title>Selenium Easy Confirm popup Sample </title>
</head>
<body>
<h2>Confirm Box Example</h2>
<fieldset>
<legend>Confirm Box</legend>
<p>Click the button to display a confirm box.</p>
<button onclick="confirmFunction()">Click on me</button>
<p id="confirmdemo"></p>
<script>
function confirmFunction()
{
var cb;
var c=confirm("I am an Example for Confirm Box.\n Press any button!");
if (c==true)
  {
  cb="You Clicked on OK!";
  }
else
  {
  cb="You Clicked on Cancel!";
  }
document.getElementById("confirmdemo").innerHTML=cb;
}
</script>
</fieldset>
</body>
</html>

The below program will demonstrate you working on Confirmation popup using above html file.
import org.openqa.selenium.Alert;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.Test;

public class PopupsHandling {
 WebDriver driver=new FirefoxDriver();
 @Test
 public void ExampleForConfirmBox() throws InterruptedException
 {
  driver.manage().window().maximize();
  driver.get("file:///C:/path/confirmation.html");
  Thread.sleep(2000);
  driver.findElement(By.xpath("//button[@onclick='confirmFunction()']")).click();
  Alert alert=driver.switchTo().alert();
  System.out.println(alert.getText());
  alert.dismiss();
 }
}

Working with Prompt Popups.

In prompt, you can enter the text using webdriver sendkeys("text..")
The below is the sample code for prompt popup, please copy and make an html file and pass it to the webdriver as below.
<html>
<head>
<title>Selenium Easy Prompt popup Sample </title>
</head>
<body>
<h2>Prompt Box Example</h2>
<fieldset>
<legend>Prompt Box</legend>
<p>Click the button to demonstrate the prompt box.</p>
<button onclick="promptFunction()">Click on me</button>
<p id="promptdemo"></p>
<script>
function promptFunction()
{
var x;
var person=prompt("Please enter your name","Your name");
if (person!=null)
  {
  x="Hello " + person + "! Welcome to Selenium Easy..";
  document.getElementById("promptdemo").innerHTML=x;
  }
}
</script>
</fieldset>
</body>
</html>

The below program will demonstrate you working on prompt popup using above html file.
import org.openqa.selenium.Alert;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.Test;

public class PopupsHandling {
 WebDriver driver=new FirefoxDriver();
 
 @Test
 public void ExampleForPromptBox() throws InterruptedException
 {
  driver.manage().window().maximize();
  driver.get("file:///C:/path/prompt.html");
  Thread.sleep(2000);
  driver.findElement(By.xpath("//button[@onclick='promptFunction()']")).click();
  Alert alert=driver.switchTo().alert();
  driver.switchTo().alert().sendKeys("Helllo");
  alert.accept();
  System.out.println(alert.getText());
 }
}

Use of Robot Class In Selenium WebDriver For Automation Purpose

During automation activity Selenium often find difficulty to find an object and perform actions which is related to mouse or keyboard type of activity. It is not easy to perform keyboard or mouse events using selenium commands. There are many specific scenarios where any selenium command is launched but actual event did not fired. This result that execution of test is stopped and it reports some error.


Here Java Robot Class come in picture. Using Robot Class we can simulate keyboard and mouse events in Selenium. This class is very easy to use with automation process. It can be easily integrate with current automation framework.

Robot Class is available under java.awt.package.


Methods in Robot Class can be effectively used to do the interaction with popups in Web Applications. Selenium does not provide support to handle browser pop-ups or the native operating system pop-ups. To handle these kind of pop-up, we need help of Robot Class. This is also used while we need to handle file upload and download activity using selenium webDriver.


The activity of file upload can also be handled using AutoIT. AutoIT is a tool that can automate the windows GUI. It generates an '.exe' file which is used by selenium script for file upload or download activity.


Some of the popular methods under Robot Class are:

.keyPress();

.mousePress();

.mouseMove();

.keyRelease();

.mouseRelease();




Here is an example to learn more about Robot Class


import java.awt.Robot;
import java.awt.Toolkit;
import java.awt.datatransfer.StringSelection;
import java.awt.event.KeyEvent;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.Test;

public class UploadFileRobot {

 String URL = "application URL";
@Test
public void testUpload() throws InterruptedException
 {
 WebDriver  driver = new FirefoxDriver();
driver.get(URL);
WebElement element = driver.findElement(By.name("uploadfile"));
element.click();
uploadFile("path to the file");
Thread.sleep(2000);
 }

/**      * This method will set any parameter string to the system's clipboard.      */
public static void setClipboardData(String string) {
//StringSelection is a class that can be used for copy and paste operations.
    StringSelection stringSelection = new StringSelection(string);
    Toolkit.getDefaultToolkit().getSystemClipboard().setContents(stringSelection, null);
 }

public static void uploadFile(String fileLocation) {
        try {
        //Setting clipboard with file location
            setClipboardData(fileLocation);
            //native key strokes for CTRL, V and ENTER keys
            Robot robot = new Robot();

            robot.keyPress(KeyEvent.VK_CONTROL);
            robot.keyPress(KeyEvent.VK_V);
            robot.keyRelease(KeyEvent.VK_V);
            robot.keyRelease(KeyEvent.VK_CONTROL);
            robot.keyPress(KeyEvent.VK_ENTER);
            robot.keyRelease(KeyEvent.VK_ENTER);
        } catch (Exception exp) {
        exp.printStackTrace();
        }
    }
}

Monday, September 21, 2015

Locators in Selenium Webdriver

PSelenium webdriver uses 8 locators to find the elements on web page. The following are the list of object identifier or locators supported by selenium.

We have prioritized the list of locators to be used when scripting.

id - >

Select element with the specified @id attribute.

Name

Select first element with the specified @nameattribute.

Linktext

Select link (anchor tag) element which contains text matching the specified link text

Partial Linktext

Select link (anchor tag) element which contains text matching the specified partial link text

Tag Name

Locate Element using a Tag Name .

Class name

Locate Element using a Tag Name ..

Css

Select the element using css selectors. You can check here for Css examples and You can also refer W3C CSS Locatros

Xpath

Locate an element using an XPath expression.

Locating an Element By ID:
The most efficient way and preferred way to locate an element on a web page is By ID. ID will be the unique on web page which can be easily identified.
IDs are the safest and fastest locator option and should always be the first choice even when there are multiple choices, It is like an Employee Number or Account which will be unique.
Example 1:

<div id="toolbar">.....</div>

Example 2:

<input id="email" class="required" type="text"/>

We can write the scripts as

WebElement Ele = driver.findElement(By.id("toolbar"));

Unfortunately there are many cases where an element does not have a unique id (or the ids are dynamically generated and unpredictable like GWT). In these cases we need to choose an alternative locator strategy, however if possible we should ask development team of the web application to add few ids to a page specifically for (any) automation testing.

Locating an Element By Name:
When there is no Id to use, the next worth seeing if the desired element has a name attribute. But make sure there the name cannot be unique all the times. If there are multiple names, Selenium will always perform action on the first matching element
Example:

<input name="register" class="required" type="text"/> WebElement register= driver.findElement(By.name("register"));

Locating an Element By LinkText:
Finding an element with link text is very simple. But make sure, there is only one unique link on the web page. If there are multiple links with the same link text (such as repeated header and footer menu links), in such cases Selenium will perform action on the first matching element with link.

Locating an Element By Partial LinkText:
In the same way as LinkText, PartialLinkText also works in the same pattern.

User can provide partial link text to locate the element.

Locating an Element By TagName:
TagName can be used with Group elements like , Select and check-boxes / dropdowns.
below is the example code:

Select select = new Select(driver.findElement(By.tagName("select"))); select.selectByVisibleText("Nov"); or select.selectByValue("11");

Locating an Element By Class Name:
There may be multiple elements with the same name, if we just use findElementByClassName,m make sure it is only one. If not the you need to extend using the classname and its sub elements.
Example:

WebElement classtest =driver.findElement(By.className(“sample”));

CSS Selector:
CSS mainly used to provide style rules for the web pages and we can use for identifying one or more elements in the web page using css.
If you start using css selectors to identify elements, you will love the speed when compared with XPath. Check this for more details on Css selectors examples

We can you use Css Selectors to make sure scripts run with the same speed in IE browser. CSS selector is always the best possible way to locate complex elements in the page.

Example:

WebElement CheckElements = driver.findElements(By.cssSelector("input[id=email']"));

XPath Selector:
XPath is designed to allow the navigation of XML documents, with the purpose of selecting individual elements, attributes, or some other part of an XML document for specific processing

There are two types of xpath

1. Native Xpath, it is like directing the xpath to go in direct way. like
Example:
html/head/body/table/tr/td

Here the advantage of specifying native path is, finding an element is very easy as we are mention the direct path. But if there is any change in the path (if some thing has been added/removed) then that xpath will break.

2. Relative Xpath.
In relative xpath we will provide the relative path, it is like we will tell the xpath to find an element by telling the path in between.
Advantage here is, if at all there is any change in the html that works fine, until unless that particular path has changed. Finding address will be quite difficult as it need to check each and every node to find that path.
Example:
//table/tr/td

Example Syntax to work with Image

    xpath=//img[@alt='image alt text goes here']

Example syntax to work with table

    xpath=//table[@id='table1']//tr[4]/td[2]     xpath=(//table[@class='nice'])//th[text()='headertext']/

Example syntax to work with anchor tag

    xpath=//a[contains(@href,'href goes here')]     xpath=//a[contains(@href,'#id1')]/@class

Example syntax to work with input tags

    xpath=//input[@name='name2' and @value='yes']

We will take and sample XML document and we will explain different methods available to locate an element using Xpath

Sunday, June 21, 2015

Where Does Windows Store Temporary Files and How to Change TEMP Folder Location?

Whenever we talk about free-up disk space on Windows PC, we always suggest to clear "TEMP" folder. Deleting all files and folders present in "TEMP" folder might provide you a decent amount of free space.
You might be wondering what is this "TEMP" folder and why is it created by Windows? "TEMP" folder, as the name suggests, is used to store temporary files and folders which are created by Windows services and many 3rd party software programs. Since the files and folders stored in Temp folder are temporary, its absolutely safe to remove them.
Now the question comes how to access this Temp folder to clear its content. There are 2 Temp folders present in Windows OS:
  • Temp folder present in C:\Windows folder
  • Temp folder present in Local Settings folder for each logged-in user
First "Temp" folder which is found in "C:\Windows\" directory is a system folder and is used by Windows to store temporary files.
Second "Temp" folder is stored in "%USERPROFILE%\AppData\Local\" directory in Windows Vista, 7 and 8 and in "%USERPROFILE%\Local Settings\" directory in Windows XP and previous versions. This folder is different for each Windows user i.e., each logged-in user gets a separate "Temp" folder. This "Temp" folder is used by 3rd party programs to store their temporary files for example, temporary downloaded parts of files by your download manager software, etc.
To access these 2 "Temp" folders, you need to use following commands:
  • TEMP
  • %TEMP%
You can run these commands in RUN dialog box or start menu search box. When you run TEMP command, it opens system "Temp" folder stored in C:\Windows directory and when you run %TEMP% command, it opens the user temp folder stored in "%USERPROFILE%" directory. You can learn more about these kind of environment variables using following tutorial:
List of Environment Variables in Windows XP, Vista and 7
Today in this tutorial, we'll show you how to tell Windows to use a single "Temp" folder for both system and user temporary files so that we don't need to open 2 different folders to free-up disk space.
We'll also learn changing location of "Temp" folder from C:\ drive to some other partition. The reason behind changing the location is very simple! First, it'll not eat valuable disk space of our system drive. Second, we'll not need to worry about clearing content of Temp folder regularly to free-up disk space on C: drive. It might also speed up your system a little bit.
So without wasting time, lets start the tutorial:
1. Right-click on Computer icon on Desktop and select Properties (or press WIN + Pause/Break keys). Now click on Advanced system settings link in left side pane. (You can open it directly by giving sysdm.cpl command in RUN or start menu search box)
2. Now click on Environment Variables button. It'll open a new window which will show a list of all environment variables defined in your Windows.
There would be 2 different sections:
  • User variables
  • System variables
You'll see TEMP and TMP variables listed in User variables section. The System variables section will contain a long list of various environment variables along with TEMP and TMP variables as shown in following screenshot:
Default_TEMP_Environment_Variable_Windows.png
3. Now to change location of TEMP folder from C:\Windows\Temp to other partition, first we'll need to create a new TEMP folder in the desired partition.
In this example, we are going to move TEMP folder location to D:\ drive, so we'll create a new folder "TEMP" in D:\ drive. Please note that you can use any name for the new folder, its not necessary to have TEMP as its name.
Now you can double-click on the TEMP variable present in System variables section or select it and click on Edit button. Now type location of new TEMP folder (which is D:\Temp in our case) and click on OK button.
Repeat same step for TMP variable as well.
That's it. It'll change the location of TEMP folder in Windows.
4. Now we'll ask Windows to use a single TEMP folder for both system and user temporary files. We can do this by either deleting both TEMP and TMP variables listed in User variables section or edit the variables and set their values to the same folder which we used for system variables in step 3 i.e., D:\Temp folder.
Once you delete both variables in User variables section or set their values to new TEMP folder path, it'll tell Windows to use a single TEMP folder to store all temporary files and folders created by Windows as well as 3rd party software programs.
Changing_TEMP_Environment_Variable_Windows.png
5. You'll need to restart your system to take effect.