B-22 Interview Questions / Automation/ SDET

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

Why do we create frameworks?

- Frameworks are created to apply reusability, maintainability, to create easy-to-use, easy-to-understand structure for our project. - Usually we implement some certain file and folder structure and proven design patterns to make our project all the "bilities".

What is Tags?

- Tags are used to group different Feature files and scenarios together to be able to run them in different test suites. - @SmokeTest Suite - @Regression Suite

Can you explain BDD steps?

1- We write feature files : scenarios and steps first 2- Then we run our code to get our snippets (empty step_definition methods) 3- We implement the step_definitions using JAVA+SELENIUM+JUNIT ETC so that it automates the browser

Why we use Actions class in Selenium?

Actions class is used for "advanced" mouse and keyboard actions

Test Base in Selenium Java

Base class is the main class which takes care of Browser setup, loading configuration file and other reusable methods like screenshot, handling sync issues and many more.

What is Maven?

Build automation tool (mainly) for java project

Why do we use Maven?

Maven helps us create and manage projects easily Maven projects will come with certain folder structure (such as main, test, pom.xml)

Definition of 'Monkey Testing'

Monkey testing is a type of software testing in which a software or application is tested using random inputs with the sole purpose of trying and breaking the system. There are no rules in this type of testing. It completely works on the tester's mood or gut feeling and experience.

How do we handle Checkboxes and radio buttons?

We locate checkboxes/radiobuttons using any locator and click(). checkbox.click();

dryRun

dryRun expects a boolean value. - if dryRun value is "true", it will NOT run the code implementation. - it will only check if all of the steps have step_definition snippets in the package - if there are steps that does not have matching snippets, than Cucumber will auto-generate an empty snippet and provide us in console - dryRun = false --> we will run all of the code as is, normally. snippet: unimplemented step definition methods

How many types of xpath are there?

#1- Absolute Xpath: Starts with "/". Starts from the very beginning of the HTML (root element = html) It goes down 1by1, therefore it is very long and not dependable. It will easily break with any minimal change in the html code. #2- Relative Xpath: Starts with "//" means it starts from anywhere in the HTML page. Relative xpath is very dependable because we either directly start from the web element we want to locate, or we start from somewhere close (parent or child)

- How do we read from .properties file?

#1- Creating an object of the Properties class Properties properties = new Properties(); #2- Use FileInputStream to open our .properties file in java memory FileInputStream file = new FileInputStream("pathOfTheFileWeAreTryingToOpen"); #3- Load the already opened "file" into the "properties" object properties.load(file); #4- Use .getProperty method from "properties" object to read keys' values. properties.getProperty("key");

How do we implement POM Design Pattern?

#1- Every time we create a new java class for each page of the application we need to initialize the browser driver instance and the object of that specific class. We need to pass: PageFactory.initElements(driver, this); #2- Instead of using findElement/s we use @FindBy annotation

How do you handle dynamic web elements?

#1- I would find a static parent/child and move from there to desired web element #2- I would use one of the methods provided by xpath locator: starts-with, ends-with, contains //tagName[contains(@attribute,'value')] //tagName[starts-with(@attribute,'value')] //tagName[ends-with(@attribute,'value')]

What are the advantages of using Page Object Model Design Pattern?

#1- Re-usability - We are creating ONE LOCATOR, ONE TIME, in ONE CLASS (in its own page class.) - We keep re-using the same web Element #2- Easy to maintain: - Since we locate each web element only once, when we have issue, we will only go to ONE CLASS to fix it. #3- Easy to understand from scratch - It will be very easy to understand/explain everyone in the team - We basically create java classes with the functionality or page name

Some of Maven plugins

#1:Maven compiler plugin•Forces the maven compiler level to Java 8 or given version #2:Maven Surefire Plugin•This plugin allows us to run maven lifecycle commands #3:Maven Cucumber Reporting (plugin)•Custom plugin that is allowing us to create a prettier and more detailed report compared to what cucumber have by default•Maven cucumber reporting uses cucumber json reporting to generate its own report

TDD : Test Driven Development

(Bug free development) - This is one of the most commonly used development approaches. - Bug-free from Unit testing perspective.

How do you use the OOP Concept in your framework?

- Encapsulation: Driver - make private WebDriver - create getter Method : getDriver(); - Polymorphism - Driver util - Inheritance / Abstract - TestBase - BasePage

What are some of the disadvantages of Selenium?

- No costumer service - No built in reporting. We need to use additional libraries to generate reports. - Only web applications : Selenium is restricted with the browser. Therefore only web pages can be automated using selenium. - Requires advanced programming language to use Selenium

What is the differences between @findby and pageFactory?

- PageFactory.initElements method allows us to initialize our Driver instance and the object of the class. - @FindBy annotation allows us to implement PageObjectModel and locate web elements without using .findElement method. - FindBy is used to support Page Object Model pattern through PageFactory

What is hard coding?

- Putting data (in our case test data) inside of the source code. - If I have to go inside of my tests(code) to change my data, it means I am hard coding.

configuration.properties - Why are we using this file?

- REUSABILITY - Easy to maintain - To avoid hard coding some of the important test data in our project

DDT : Data Driven Testing

- Running the same tests against different test data - We keep the "data" separated from "source code"

What is Singleton Design Pattern? How do we apply Singleton Design Pattern?

- Singleton Design Pattern guarantees to deliver same OBJECT every time. #1- We create private constructor. #2- We create a getter method to deliver the object of the class in the way we want to deliver.

What is TestNG ANNOTATIONS?

- The primary goal of annotation is to change the behavior of existing method. - If we apply a TestNG annotation to a simple java method, it will become TestNG property. - It means it will not be only Java method anymore. - It will be acting the way TestNG intends. Common annotations:- @Test- BeforeMethod, AfterMethod- BeforeClass, AfterClass- BeforeTest, AfterTest- BeforeSuite, AfterSuite

What is the main goal of the Singleton Design pattern?

- avoid null pointers - to return the same object everytime we call the getter method Singleton means 1 instance, in our case it means 1 WebDriver object. We use it because its easy to share Driver object across the project. Also its easy to make sure that every test using exactly the same driver object.

Difference: - driver.quit(); - driver.close();

- driver.quit(); --> it will close all of the opened browsers and tabs--> it will terminate the driver instance completely - driver.close(); --> closes only the currently opened browser or tab--> it will end the session

How does project knows where to find the Hooks class?

- glue

What is plugin?

- plugin keyword allows us to implement different types of report in cucumber runner class. plugin = "html:target/cucumber-report.html" "html: --> we are saying we want to create "html" type report target/ --> we are specifying we want to create this under target folder cucumber-report.html --> we are providing the name of the report file

What is Hooks?

- will allow us to create pre and post conditions for each scenario AND EACH STEP. - @Before and @After annotations - Before and After will be executed before&after each SCENARIO. - @BeforeStep and @AfterStep annotations - BeforeStep and AfterStep will be executed before&after each STEP. - may be useful in buggy situation where we have to take screenshot before and after each step (or when scenario fails) - Hooks class name is only conventional. - We could use different class name, and it would still work. - But we must import from io.cucumber instead of JUnit - Hooks will be executed before the feature files.

What is Background?

- will allow us to have repeating set-up steps ONLY 1 time in the feature file. - if we write in once, we don't have to have separately for each scenario repeatedly. - Background will only be applied to "Scenario"s in the current .feature file. - We can only create pre-condition (similar to @BeforeMethod in TestNG) - We can not make it run after each Scenario. - When we use Background, we MUST make sure ALL of the scenarios are able to continue where the steps from Background left off.

How do we go from parent to child using xpath?

/ This will go to direct child // --> will go any child regardless of hierarchy (grand childs as well) -How do we go to parent from child? /.. This will go to direct parent.

How do we take a screenshot using your framework?

1) I create and use the object of Scenario class, which tracks a few information about currently executed scenario. 2) I downcast my WebDriver type to TakesScreenshot interface type. 3) I store my screenshot into an array of bytes. 4) Use the scenario object to attach the screenshot into our report. 5) If I don't want to take a screenshot after each scenario or step, I will create a simple if condition where I track if scenario is failed or not.- If scenario fails --> take screenshot. if (scenario.isFailed()){byte [] screenshot = ((TakesScreenshot) Driver.getDriver()).getScreenshotAs(OutputType.BYTES);scenario.attach(screenshot, "image/png", scenario.getName());}

How many different ways you can scroll?

1- Actions method called .moveToElement() 2- sendKeys(Keys.PAGE_DOWN) or sendKeys(Keys.PAGE_UP) 3- scroll using JavaScriptExecutor: js.executeScript("window.scrollBy(0, 750)"); 4- OPTION 2 FOR JSEXECUTOR: js.executeScript("arguments[0].scrollIntoView(true)", cybertekSchoolLink);

Can you explain how you set up parallel testing?

1- I use different plugins to achieve parallel testing. 2- Maven compiler plugin makes sure my compiler level is java 8 3- Maven surefire plugin allows me to pass different configurations that allows to run my feature files in parallel to each other. - I can also pass the number of threads that I want to open in parallel to each other. 4- I adjusted my Driver class to be able to generate as many driver object as needed, using ThreadLocal class. 5- I use "synchronized" block to make sure multiple threads are not going for the same driver instance. 6- When I kick off my tests from mvn verify command, it will trigger my "maven surefire plugin" and my tests are executed in parallel

How to achieve TDD?

1- Write (unit) tests first without writing any code 2- Run the tests 3- Tests will fail 4- Write minimum amount of code to pass the tests 5- Run the tests again 6- Tests will pass 7- Optionally refactor the code: add more features, make it easier to use, make the web application faster etc.

BDD Behavior - Driven Development

2 layers/sides. #1- Business Layer/ - Business side is for non-technical people ( Gherkin language ) #2- Implementation Layer/ - Where we actually implement JAVA+Selenium etc

Fluent Wait

A FluentWait instance defines the maximum amount of time to wait for a condition to take place, as well as the frequency with which to check the existence of the object condition. Let us say we will 60 seconds for an element to be available on the page, but we will check its available once in every 10 seconds. Wait wait = new FluentWait(driver).withTimeout(60, SECONDS).pollingEvery(10, SECONDS).ignoring(NoSuchElementException.class); WebElement dynamicelement = wait.until(new Function<webdriver,webElement>() { public WebElement apply(WebDriver driver) { return driver.findElement(By.id("dynamicelement")); } });

What is APACHE POI? (Dependency)

Apache POI is a dependency created by a company called APACHE SOFTWARE FOUNDATION

What is an API?

Application Programming Interface An API (Application Programming Interface) is a set of functions that allows applications to access data and interact with external software components, operating systems, or microservices.

What does assertions do?

Assertions verify expected and actual values. - It can be string, int, List<String> , List<WebElement>- Assertions will determine if a test PASSES OR FAILS. - This result(Pass or Fail) will be reflected in the test reports. - If an assertion fails, the rest of the lines after that assertion in the same test will NOT be executed. - assertTrue(boolean returning statement) - assertEquals(string1, string2)

What is a dependency?

Bunch of jar files: java classes, libraries ready to use•So we add to our project and readily use them•Dependencies are not involved in Maven lifecycles•They are just ready jar files, we add and use

Page Object Model Design Pattern

Creating java class for each page of the web application we are working on - We store relevant webElement, methods into its own java class.

What's CUCUMBER?

Cucumber is a software tool that supports behavior-driven development (BDD). Cucumber does NOT have assertions that comes with it. ---> That's why we are using JUnit (Unit testing tool) to use assertions come from that library. Cucumber is BDD tool, that allows us to implement BDD approach.

What is a framework?

Framework is a conceptual and technological support structure defined, with specific software artifacts or modules, which can serve as a basis for the organization and development of software. - Frameworks are basically commonly used, and proven approaches of creating file, folder structure and implementing smart logic (and design patterns) in handling programming logics and approaches in a better way.

What is JavaScriptExecutor? How do we use JavaScriptExecutor?

It is a simple interface in Selenium Library. 1- We downcast our driver type to JavaScriptExecutor type.2- We can create object of JavaScriptExecutor3- Call the methods from there.

What is Driver utility and why did we create it?

It is a utility class we created so that we can re-use our WebDriver and make sure it will return us same driver instance every time we call it.

Why we can not use parallel tests with Singleton? And how we can solve this problem?

It limits our code so that we cannot run with multi threads. What is the solution?•We will use ThreadLocal class from Java to create driverPool •ThreadLocal is a class that creates the object of the given class PER THREAD. •You can think of it as this class will provide us with a pool of drivers, where our code will be able to go and use as many as needed. •driverPool.remove() - will remove particular object for given thread. We will use this instead of driver.quit() driverPool.set() - set/add object •For setting, creating webdriver driverPool.get() - return object

Assertions syntax in JUnit (Cucumber) and TestNG

JUnit : Assert.assertTrue("failure message here!", something.equals("something")) ; TestNG : Assert.assertTrue(something.equals("something"), "failure message here!");

What are locators in Selenium?

Locators are methods that help us locate WebElements. There are 8 locators linktext, partialLinkText, id, className, name, tagName, cssSelector, xpath

Why are we not using TestNG and using JUnit with Cucumber?

Majority of the community is using JUnit with Cucumber. - More questions - More answers - More opportunities

What are maven lifecycles?

Maven is based around the central concept of a build lifecycle. •What this means is that the process for building and distributing a particular artifact (project) is clearly defined.•For the person building a project, this means that it is only necessary to learn a small set of commands to build any Maven project, and the POM will ensure they get the results they desired.

Where does maven store all of the dependencies?

Maven stores dependency related files/folders in .m2 If you add dependency or change a version of dependency, and it creates a problem, you might want to consider deleting everything in the .m2 file and "reload" your project.

Why are we using Selenium? What are the advantages of using selenium?

Open source ---> Free supports many programming langugages supports multiple platforms: Windows, Mac, Linux supports multiple browsers There is a huge community behind selenium (using it) which means there are many solutions to any problems

The line in Cucumber that allows you to find elements with @FindBy annotation?

PageFactory.initElements(Driver.getDriver(),this);

What is a plugin?

Plugins are actually jar files just like dependencies •They are very similar but plugins are involved in the maven lifecycles •Most of the work in the maven lifecycle are done by plugins Plugins: ARE VERY SIMILAR TO DEPENDENCIES. - Basically Plugins are DEPENDENCIES with additional configuration. - We can change values from plugins and when we kickoff our tests from Maven Lifecycles, it will be immediately applied to our project/tests.

What is build?

Repeating steps when we are creating the project, such as: creating the folders, adding, compiling, testing, deploying ( all of these steps are called build)

What is the triggering point of your project? Where do you run your project from?

Runner class - The whole project is controlled by the Runner (CukesRunner) class - Thats why we need to make sure Runner class is connected to rest of the project - Meaning: - Runner class should know where the step definitions are (glue) - Runner class should know where the feature files are stored (feature) - Runner class should know whether I want to dryRun true or false (dryRun) - Runner class should know what kind of report I want to generate (plugin) - Runner class should know which tests I want to run (tags)

What is Data Driven Testing?

Running the same tests against different data set.

What is DATA DRIVEN TESTING? (DDT)

Running the same tests against different test data. test1 - username: tester1 - password: test test1 - username: tester2 - password: test

What is Selenium?

Selenium is an open source library (jar files) to automate browsers

Tags in Runners --> CukesRunner

Tags allow us to create different test-suites - We can include or exclude different scenarios and different feature files - If we put the tag on top of a "Scenario:" it will only effect that scenario. - If we put the tag on top of a Feature file, it will effect the whole feature file and all of the scenarios in it. --> Using "or" in the tags: - "or" will check either side of the tags. - If the scenario has either one of the tags, it will be executed. - This is very similar to "or" --> || --> in java a || b ex: tags = "@librarian or @employee" --> Using "and" in the tags: - This is very similar to "and" --> && --> in java - "and" will check both sides of the tags. - It will only run the scenario if it contains both of the given tags a && b ex: tags = "@librarian and @employee" tags = "@regression and not @student" --> This will run all of the feature files and scenarios that has regression, but it will exclude all scenario that has @student tag

What is TestBase?

TestBase is an abstract class where we store and re-use some repeating logic and common variables. - TestBase is parent of all other tests we create in a project. - If we decide to use TestBase, we would have to extend to TestBase from all the classes we have tests in. - If we have a logic that applies all of the tests in our testing suite, we can use TestBase.

What is cross browser testing?

Testing the same test suite against different browsers. - We are able to do cross-browser testing by changing our test data (browser key) from configuration.property

What is TestNG?

UNIT TESTING FRAMEWORK. - It has NOTHING to do with selenium. - Is this tools created for testers?- No. It is for developers to create unit testing structure. We use TestNG to use some of its annotations, such as (beforeMethod, afterMethod, beforeClass, afterClass etc)

What is a snippet?

Unimplemented step definition methods that are provided to us from Cucumber by default.

How do you run your failed runner?

Using Cucumber RERUN plugin and creating a seperate FailedTestRunner class to execute failed tests from rerun.txt

How does Runner class know where to find and compare "feature" files and "step definitions"?

We provide paths in our Runner class @CucumberOptions glue = the path of the step_definitions package features = the path of the directory where all .feature files are stored

What is the triggering point of your project?

We run the whole project from the Runner class. "CukesRunner" - All the necessary details of the project are provided in the Runner class. 1- I use @RunWith annotation be able to run my .java class with my Cucumber tool 2- I use @CucumberOptions annotation to provide details about my project. - features = details for where I am storing my feature files. - glue = Where I am storing actual implementation - the path of the --> step_definitions package

What kind of data we are storing in configuration.properties?

We store the important test data that can change the flow of the whole test suite - We store the data in key=value format

How do you decide which locator to use?

What is your locator strategy? #1- If there is "id" I make sure it is not dynamic and use it. #2- If not, I check if the "class" attribute is unique using cssSelector. #3- If it is a link WebElement, I use linkText #4- If none of the previous works/applies, I go for xpath

What is a WebElement?

Whatever we see on a web page is a WebElement, such as: buttons, links, images etc.

How do you use external data? Can you explain step by step?

excel - configuration.properties - feature files : accepting parameters from feature files using data tables, and scenario outlines

What are the difference between findElement() vs findElements() methods?

findElement() Return type: WebElement Returns a single web element findElements() Return type: List Capable of finding and returning multiple web elements in a List of web elements

What happens if it doesn't find a web element / findElement() vs findElements() ?

findElement() - Throws NoSuchElementException findElements() - It will return empty List. (It will not throw exception).

Methods that will will be used to handle multiple windows in Selenium

get.windowhandle() - Get window handle of the current window get.windowhandles() - Get window handles of all opened windows set - Set the window handles in a form of a String. Ex: string.set<string> set = driver.get.windowhandles(). switch to - Switch between the windows. action - Perform certain actions on the windows.

What are the differences between getText and getAttribute method?

getText: Return: String. Only gets the text from between opening tag and closing tag. getAttribute: Return: String. Finds matching attribute on a given web element, and returns the attribute's value as a String.

How do we verify if checkbox is selected or not?

isSelected() method is used to verify. - returns "true" if checkbox is selected - returns "false" if checkbox is NOT selected checkbox.isSelected(); --> true/false

Why do we use .properties file?

it stores data in key=value format

What is pom.xml file? Why do we need this file?

pom : project object model xml : extensible markup language We add and manage dependencies and their versions from pom.xml file

Which version of Selenium do you use?

selenium version 3.141.59

If you used Singleton in your Driver, how did you handle parallel execution?

•#1-I wrapped my WebDriver object with ThreadLocal that creates copy of driver object per thread.•Then inside getDriver method, I have synchronized block that controls access of threads so multiple threads are not trying to access same piece of code at the same time.• #2-Create multiple runner classes

CUCUMBER RERUN PLUGIN

•Cucumber rerun plugin allows us to store failed tests scenarios in a file •We can run those scenarios using another(!) runner class / ex: FailedTestRunner

Why do we use parallel testing?

•Save time •Cucumber supports parallel testing out of the box since version 4

How do you handle downloads using Selenium?

•Selenium cannot reach outside of the browser.

How do we handle uploads using Selenium?

•You can handle uploads using sendKeys method. •And the way to do it is, to locate the upload button, and send the path of the file using sendkeys. •Just sendkeys without clicking


Ensembles d'études connexes

Week 1 - Chapter 3: Health, Wellness, and Health Disparities

View Set

Civics Midterm Exam study Guide Grade 7

View Set

Business Result Pre-Intermediate - Unit 2

View Set

Nursing Concepts PrepU Practice Questions - Ch. 19

View Set

CHAPTER 13-15/16 US HISTORY TO 1877 MULTIPLE CHOICE

View Set

C) Give the meaning of the following suffixes

View Set