41, How to solve Merge conflict in GIT?

 As we are only 2 tester working on this project, if we have any merge conflict I used to pull all the latest file/scripts to my local system. Then I will analyze the difference between that particular file and merge file. After that I will check with my team member whether all his imp things are covered then I will add my steps and push the script to the central repo.


42,You have worked in Jenkins can you tell me how you have created jobs in Jenkins? 

We have separate Dev-Ops Team to create Jenkins jobs at broad level but we also have access to jenkins, so we have created jobs for our internal purpose. For creating any job we have click on create new job->inside that give name of your job->select freestyle project->then add. Beside that we can provide description of our project and in source code management we can choose Git-> provide repo url ->after that provide some schedule if you want to run the job on any specific schedule time.-> select window batch command-file location-save-click on build now for running. After triggering we can check log in console.


43,What is the difference between Smoke & Sanity Testing? 

Smoke and Sanity we can are like same thing because both are checking important functionality. Smoke testing is done on first stable build from developer to check like whether it is stable enough to move further or not. While Sanity testing is subset of regression test which we perform on stable build and here also we used to check all the imp functionality. 


44) What is the difference between Soft Assert and Hard Assert in Selenium?


Hard Assert throws an AssertException immediately when an assert statement fails and test suite continues with next @Test. It marks method as fail if assert condition gets failed and the remaining statements inside the method will be aborted.

Soft Assert collects errors during @Test. Soft Assert does not throw anexception when an assert fails and would continue with the next step after the assert statement.

45) What are the verification points available in Selenium?


Different types of verification points in Selenium are:

To check element is present

if(driver.findElements(By.Xpath(“value”)).size()!=0)
{
System.out.println(“Element is present”);
}
else
{
System.out.println(“Element is absent”);
}

To check element is visible

if(driver.findElement(By.Id(“submit”)).isDisplayed())
{
System.out.println(“Element is visible”);
}
else
{
System.out.println(“Element is visible”);
}

To check element is enabled

if(driver.findElement(By.Id(“submit”)).isEnabled())
{
System.out.println(“Element is enabled”);
}
else
{
System.out.println(“Element is disabled”);
}

To check text is present

if(driver.getPageSource().contains(“Text”))
{
System.out.println(“Text is present”);
}
else
{
System.out.println(“Text is not present”);
}

46) Why do we create a reference variable ‘driver’ of type WebDriver and what is the purpose of its creation?


We create an instance of the WebDriver interface and cast it to different browser class using the reference variable ‘driver’. 

Then we can use different methods of the web driver interface like get(), getTitle(), close(), etc…to write automation code.

47) What are the different types of exceptions you have faced in Selenium WebDriver?

Different types of exceptions in Selenium are:

  • NoSuchElementException
  • NoSuchWindowException
  • NoSuchFrameException
  • NoAlertPresentException
  • ElementNotVisibleException
  • ElementNotSelectableException
  • TimeoutException

48) How to login into any site if it is showing an authentication pop-up for Username and Password?


To work with Basic Authentication pop-up (which is a browser dialogue window), you just need to send the user name and password along with the application URL.

Syntax:

driver.get("http://admin:admin@yoururl.com");

49) What is Fluent Wait in Selenium WebDriver?


Each FluentWait instance defines the maximum amount of time to wait for a condition, as well as the frequency with which to check the condition.Furthermore, the user may configure the wait to ignore specific types of exceptions whilst waiting, such as NoSuchElementExceptions when searching
for an element on the page.

Syntax:

Wait<WebDriver> wait1 = new FluentWait<>(driver)
.withTimeout(Duration.ofSeconds(30))
.pollingEvery(Duration.ofSeconds(5))
.ignoring(NoSuchElementException.class);
WebElement element = wait1.until(new Function<WebDriver, WebElement>() 
{
@Override
public WebElement apply(WebDriver driver)
{
return driver.findElement(By.id("firstName"));
}
});

50) How to input text into the text box fields without calling the sendKeys()?


We can use Javascript action to enter the value in text box.

Syntax:

JavascriptExecutor executor = (JavascriptExecutor)driver;
executor.executeScript("document.getElementById("textbox_id").value='new value’”);

51) What is Page Factory?


Page Factory class in Selenium is an extension to the Page Object Design pattern. It is used to initialize the elements of the page object or instantiate the page objects itself.
Annotations in Page Factory are like this:

Syntax:

@FindBy(id = “userName”)
WebElement txt_UserName;

We need to initialize the page object like this:

PageFactory.initElements(driver, Login.class);

52) What is the difference between Page Object Model and Page Factory?


Page Object Model is a design pattern to create an Object Repository for web
UI elements. However, Page Factory is a built-in class in Selenium for
maintaining object repository.

53) How to upload a file in Selenium WebDriver?


Uploading files in WebDriver is done by simply using the sendKeys() method on the file-select input field to enter the path to the file to be uploaded.

Syntax:

driver.get(baseUrl);
WebElement uploadElement = driver.findElement(By.id("uploadfile_0"));
// enter the file path onto the file-selection input field
uploadElement.sendKeys("Path");

54) How to download a file in Selenium WebDriver?


Step 1- Create a firefox Profile.
Step 2- Set Preferences as per requirement.
Step 3- Open Firefox with firefox profile.

public class DownloadFiles 
{
public static void main(String[] args) 
{
// Create a profile FirefoxProfile profile=new FirefoxProfile();
// Set preferences for file type profile.setPreference("browser.helperApps.neverAsk.openFile",
"application/octet-stream");
// Open browser with profile
WebDriver driver=new FirefoxDriver(profile);
// Set implicit wait driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
// Maximize window driver.manage().window().maximize();
// Open APP to download application driver.get("http://www.file.com/download_file”);
// Click on download driver.findElement(By.xpath(“path”)).click();
}
}

55) How to connect to a database in Selenium?


Connection con = DriverManager.getConnection(dbUrl,username,password);
25) How to resize browser window using Selenium WebDriver?
driver.manage().window().maximize();

56) How to clear the text inside the text box fields using Selenium WebDriver?

Syntax:

driver.findElement(By.Id(“textbox_id”)).clear();

57) How to get an attribute value of an element using Selenium WebDriver?


driver.findElement(By.Id(“button_id”)).getAttribute(“text”);

58) How to press Enter key on text box in Selenium WebDriver?


driver.findElement(By.Id(“button_id”)).sendKeys(keys.ENTER);

59) How to pause a test execution for 5 seconds at a specific point?

We can pause test execution for 5 seconds by using the wait command.

Syntax:

driver.wait(5);

60) Is Selenium Server needed to run Selenium WebDriver scripts?


In case of Selenium WebDriver, it does not require to start Selenium Server for executing test scripts. Selenium WebDriver makes the calls between browser & automation script.

Post a Comment

Previous Post Next Post