What is a Build Tool?
A build tool is a tool that automates everything related to building the software project. Building a software project typically includes one or more of these activities:
- Generating source code (if auto-generated code is used in the project).
- Generating documentation from the source code.
- Compiling source code.
- Packaging compiled code into JAR files or ZIP files.
- Installing the packaged code on a server, in a repository or somewhere else.
mvn clean install  --->    # Cleans + compiles + packages + installs
Running Maven
- When you have installed Maven and have created a POM file and put the POM file in the root directory of your project, you can run Maven on your project.
 Running Maven is done by executing themvncommand from a command prompt. When executing themvncommand you pass the name of a build life cycle, phase or goal to it, which Maven then executes. Here is an example:
 mvn install
 This command executes the build phase calledinstall(part of thedefaultbuild life cycle), which builds the project and copies the packaged JAR file into the local Maven repository. Actually, this command executes all build phases beforeinstallin the build phase sequence, before executing theinstallbuild phase.
 You can execute multiple build life cycles or phases by passing more than one argument to themvncommand. Here is an example:
  mvn clean install
 This command first executes thecleanbuild life cycle, which removes compiled classes from the Maven output directory, and then it executes theinstallbuild phase.
 You can also execute a Maven goal (a subpart of a build phase) by passing the build phase and goal name concatenated with a : in between, as parameter to the Maven command. Here is an example:
 mvn dependency:copy-dependencies
 This command executes thecopy-dependenciesgoal of thedependencybuild phase.
Running Maven is done by executing the
mvn command from a command prompt. When executing the mvn command you pass the name of a build life cycle, phase or goal to it, which Maven then executes. Here is an example:mvn installThis command executes the build phase called
install (part of the default build life cycle), which builds the project and copies the packaged JAR file into the local Maven repository. Actually, this command executes all build phases before install in the build phase sequence, before executing the install build phase.You can execute multiple build life cycles or phases by passing more than one argument to the
mvn command. Here is an example:mvn clean installThis command first executes the
clean build life cycle, which removes compiled classes from the Maven output directory, and then it executes the install build phase.You can also execute a Maven goal (a subpart of a build phase) by passing the build phase and goal name concatenated with a : in between, as parameter to the Maven command. Here is an example:
mvn dependency:copy-dependenciesThis command executes the
copy-dependencies goal of the dependency build phase.
 Unit Test Execution
SampleTest.java:
01package com.javacodegeeks;
02
03import org.junit.Assert;
04import org.junit.Test;
05
06public class SimpleTest {
07
08   @Test
09   public void test() {
10      SampleExample example = new SampleExample();
11      example.addInteger(10);
12      example.addInteger(100);
13      Assert.assertEquals(example.getSize(), 2);
14   }
15}
| 01 | packagecom.javacodegeeks; | 
| 02 | 
| 03 | importorg.junit.Assert; | 
| 04 | importorg.junit.Test; | 
| 05 | 
| 06 | publicclassSimpleTest { | 
| 07 | 
| 08 |    @Test | 
| 09 |    publicvoidtest() { | 
| 10 |       SampleExample example = newSampleExample(); | 
| 11 |       example.addInteger(10); | 
| 12 |       example.addInteger(100); | 
| 13 |       Assert.assertEquals(example.getSize(), 2); | 
| 14 |    } | 
| 15 | } | 
- 
In order for all units tests to be executed, we use the command:
1
mvn test
 
The-Dtest option specifies which unit test shall be executed:
1mvn -Dtest=SimpleTest test
Name 5 different exceptions you had in selenium web driver and mention.
In order for all units tests to be executed, we use the command:
| 1 | mvn test | 
-Dtest option specifies which unit test shall be executed:| 1 | mvn -Dtest=SimpleTest test | 
What instance you got it and how do you resolve it?
·           WebDriverException
       WebDriverException
 WebDriver Exception comes when we try to perform any action on the non-existing driver.
What instance you got it and how do you resolve it?
WebDriverException
In TestNG I have some test's Test1-Test2-Test3-Test4-Test5I want to run my execution order is Test5-Test1Test3-Test2-Test4.How do you set the execution order can you explain for that?
public class testngexecution {
@Test(priority=2)
public void test1()
{System.out.print("Inside Test1");
}
@Test(priority=4)
public void test2()
{System.out.print("Inside Test2");
}
@Test(priority=3)
public void test3()
{System.out.print("Inside Test3");
}
@Test(priority=5)
public void test4()
{System.out.print("Inside Test4");
}
@Test(priority=1)
public void test5()
{System.out.print("Inside Test5");
}
@Test(priority=2)
public void test1()
{System.out.print("Inside Test1");
}
@Test(priority=4)
public void test2()
{System.out.print("Inside Test2");
}
@Test(priority=3)
public void test3()
{System.out.print("Inside Test3");
}
@Test(priority=5)
public void test4()
{System.out.print("Inside Test4");
}
@Test(priority=1)
public void test5()
{System.out.print("Inside Test5");
}
How to refresh a page without using context click?
1.Using navigate.refresh() method
driver.navigate().refresh();
2.Using get() method
driver.get(driver.getCurrentUrl());
What is the difference between driver.Close() and driver.Quit () method?
Close() - It is used to close the browser or page currently which is having the focus.
Quit() - It is used to shut down the web driver instance or destroy the web driver instance
(Close all the windows)
Ques 32) How do you simulate scroll down action ?
Ans- Use java script to scroll down-
| 
1 
2 
3 
4 
5 
6 
7 
8 
9 
10 
11 
12 
13 
14 
15 
16 
17 
18 
19 
20 
21 
22 
23 
24 
25 
26 
27 
28 
29 
30 
31 | 
JavascriptExecutor jsx = (JavascriptExecutor)driver; 
 jsx.executeScript("window.scrollBy(0,4500)", ""); //scroll down, value 4500 you can change as per your req 
 jsx.executeScript("window.scrollBy(450,0)", ""); //scroll up 
 ex- | 
19.   How to handle internationalisation through
 web driver?
Japanese Lang
24. How can we get the font size, font color, 
font type used  for a particular text on a web
page using Selenium web driver?
driver.findelement(By.Xpath("Xpath ").getcssvalue("font-size);
web driver?
Japanese Lang
24. How can we get the font size, font color, 
font type used for a particular text on a web
page using Selenium web driver?
font type used for a particular text on a web
page using Selenium web driver?
driver.findelement(By.Xpath("Xpath ").getcssvalue("font-size);
driver.findelement(By.Xpath("Xpath ").getcssvalue("font-colour);
driver.findelement(By.Xpath("Xpath ").getcssvalue("font-type);
driver.findelement(By.Xpath("Xpath ").getcssvalue("background-colour);
What is the difference between "GET" and "NAVIGATE" to open a web page in selenium web driver?
Get method will get a page to load or get page source or get text that's all whereas navigate
will guide through the history like refresh, back, forward.For example if we want to move
forward and do some functionality and back to the home page this can be achieved
through navigate() only. driver.get will wait till the whole page gets loaded and driver.navigate
will just redirect to that page and will not wait
will guide through the history like refresh, back, forward.For example if we want to move
forward and do some functionality and back to the home page this can be achieved
through navigate() only. driver.get will wait till the whole page gets loaded and driver.navigate
will just redirect to that page and will not wait
driver.navigate().forward();
driver.navigate().back();
Command 
Purpose 
 
mvn cleanDeletes target/ folder (old compiled classes) 
 
mvn compileCompiles the source code of the project 
 
mvn test-compileCompiles the test source code 
 
mvn testRuns the unit tests 
 
mvn packageCompiles code and packages it into JAR/WAR in target/ 
 
mvn installInstalls the built artifact into your local Maven repository (~/.m2/repository) 
 
mvn deployDeploys the artifact to a remote repository (used in CI/CD) 
 
 
 
 
 
No comments:
Post a Comment