IMPORTANT:
DO NOT search the answer online or ask somebody else to help you
- Create a script using Selenium Web Driver that perform the following steps –
Note:
Use browser of your choice (IE, Chrome and Firefox)
- Open “testing.com” homepage.
- Verify the title of homepage
- Comparing and print out the result of comparison
- Closing the Browser Session
Selenium
Code :
Method
I : I am using If Statement :
------------------------------------
package
OptumUHGtest;
import
java.util.concurrent.TimeUnit;
import
org.junit.Assert;
import
org.openqa.selenium.WebDriver;
import
org.openqa.selenium.chrome.ChromeDriver;
import
org.openqa.selenium.firefox.FirefoxDriver;
public
class Test {
public
static void main(String[] args) {
//
System Property for Chrome Driver
System.setProperty("webdriver.chrome.driver",
"C:\\chromedriver.exe");
//
Instantiate a ChromeDriver class.
WebDriver driver=new ChromeDriver();
driver.manage().timeouts().implicitlyWait(10,
TimeUnit.SECONDS);
driver.navigate().to("https://www.Testing.com");
String
actualTitle = driver.getTitle();
//Maximize
the browser
driver.manage().window().maximize();
String
expectedTitle = "Health Testing and Screening Resources";
if(actualTitle.equalsIgnoreCase(expectedTitle))
System.out.println("Title
Matched");
else
System.out.println("Title
Didn't Match");
//Driver.close()
is just closing one tab of the browser.
driver.close();
//Driver.quit()
is closing all the browsers and also ending the WebDriver session
driver.quit();
}
}
RESULT
: After executing the codes : You can see the result in the console :
--------
Title
Matched
Method
II : I am Assert Command :
------------------------------------
package
OptumUHGtest;
import
java.util.concurrent.TimeUnit;
import
org.junit.Assert;
import
org.openqa.selenium.WebDriver;
import
org.openqa.selenium.chrome.ChromeDriver;
import
org.openqa.selenium.firefox.FirefoxDriver;
public
class Test {
public
static void main(String[] args) {
//
System Property for Chrome Driver
System.setProperty("webdriver.chrome.driver",
"C:\\chromedriver.exe");
//
Instantiate a ChromeDriver class.
WebDriver driver=new ChromeDriver();
driver.manage().timeouts().implicitlyWait(10,
TimeUnit.SECONDS);
driver.navigate().to("https://www.Testing.com");
String
actualTitle = driver.getTitle();
//Maximize
the browser
driver.manage().window().maximize();
String
expectedTitle = "Health Testing and Screening Resources";
Assert.assertEquals("Condition
true", actualTitle, expectedTitle);
//Driver.close()
is just closing one tab of the browser.
driver.close();
//Driver.quit()
is closing all the browsers and also ending the WebDriver session
driver.quit();
}
}
RESULT
: After executing the codes : You can see the result in the console :
--------
Title
Matched
- What is the difference between Absolute Path and Relative Path in Selenium?
Note: Consider
automating a web page using Selenium, please provide sample code to
differentiate the two.
Absolute
Xpath: It uses Complete path from the Root Element to the desire
element.
Relative
Xpath: You can simply start by referencing the element you want and
go from there.
Always
Relative Xpaths are preferred as they are not the complete paths from
the Root element. (//html//body) ..
Beacuse
in future any of the webelement when added/Removed then Absolute
Xpath changes. So Always use Relative Xpaths in your Automation.
Selenium
Code :
//
Absolute Path starts from root path, Relative Path starts from
current path
//Selenium
WebDriver - Absolute and Relative Path Examples
//Example
Absolute and Relative Paths for Selenium WebDriver
import
org.junit.Test;
import
org.openqa.selenium.By;
import
org.openqa.selenium.WebDriver;
import
org.openqa.selenium.WebElement;
import
org.openqa.selenium.chrome.ChromeDriver;
public
class AbsoluteRelativePaths {
@Test
public
void absolutePath() throws InterruptedException {
System.setProperty("webdriver.chrome.driver",
"C:\\Selenium\\chromedriver_win32\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.get("E:\\Selenium\\absolute.html");
// Absolute Path starts from root path
WebElement link1 =
driver.findElement(By.xpath("/html/body/li[@id='test']/a"));
// Relative Path starts from current path
WebElement link2 =
driver.findElement(By.xpath(".//*[@id='test']/a"));
driver.quit();
}
}
- List some scenarios which cannot be automated using Selenium WebDriver?
- We can not automate desktop Application. Selenium is only for Web Based application.Finding elements is only possible with id, css, xpath, name, partial link etc. ...With Selenium webdriver,
- Mobile testing is not possible. ...
- Captcha cannot be automated using selenium.
- Bitmap comparison is not possible using Selenium WebDriver.
- Automating Captcha is not possible using Selenium WebDriver.
- We can not read bar code using Selenium WebDriver.
- We can not automate OTP submission.
- We can not automate Video streaming scenarios: More often that not, Selenium won’t be able to recognise video controls. JavaScript Executor and flex-ui-selenium will work to some extent, but they are not entirely reliable.
- Please review the following code and answer what it refers to in Selenium?
Code:
try
{
driver.get("www.testing.com");
}catch(Exception
e){
System.out.println(e.getMessage());
}
ANSWER:
//
Try-catch: This method can catch Exceptions, which uses a combination
of the try and catch keywords.
//
Try command indicates the start of the block, and Catch is placed at
the end of the try block,
//
which helps to resolve the Exception.
try
{
//launching
URL using driver.get()
driver.get("www.testing.com");
}catch(Exception
e){
//
getMessage(): Helps to displays the description of the Exception.
System.out.println(e.getMessage());
}
- What is a requirements traceability matrix (RTM) and what are its advantages?
Given
the following requirements and test cases, Please come up with a RTM.
Requirements:
R1
- A user can log in to the system
R2
- A user can send messages to other users
R3
- A user can open the profile page
R4
- A user can edit sent messages
R5
- A user can have a profile picture
Test
cases :
TC1
- Verify that a user is able to log in
TC2
- Verify that a user can open the profile page and edit the profile
picture
TC3
- Verify that a user can send and edit messages
ANSWER
:
Requirements
traceability matrix (RTM):
100%
test coverage; It allows to identify the missing functionality
easily;
It
allows to identify the test cases which needs to be updated in case
of change in requirement;
It
is easy to track the overall test execution status
Advantage
as we update the RTM, we can know the coverage status accuratly any
time
Let
us see how our RTM coverage; Here 100% Test has been cover. TC1
Covers R1, TC2 Covers R3,R5 and TC3 covers R2 and R4.
- How will you automate basic “login” functionality of a web application? Please list down some high level test cases as well as your test plan to automate them.
1.
We can handle directly in the main method ( refer to the below and
other login code hereby.)
driver.get
(“https://www.OptumUHG.com”)
driver.find_element_by_id(“email”).send_keys(‘MyOptumUHGID@gmail.com’)
driver.find_element_by_id(“pass”).send_keys(“TempPassword1”)
driver.find_element_by_id(“loginbutton”).click()
2.
We can call the respective methods in the Optum().
public
class Optum {
static WebDriver driver= new FirefoxDriver();
@Test
public void test() {
//Method1 for Opening Browser.
openBrowser();
// Method2 for Login
LoginElement();
}
public static void openBrowser(){
driver.get
(“https://www.OptumUHG.com”)
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(20,
TimeUnit.SECONDS);
}
public static void LoginElement(){
driver.find_element_by_id(“email”).send_keys(‘MyOptumUHGID@gmail.com’)
driver.find_element_by_id(“pass”).send_keys(“TempPassword1”)
driver.find_element_by_id(“loginbutton”).click()
}
}
- What are the main attributes of test automation, List some of them?
1.Maintainability
- the effort needed to update the test automation suites for each new
release
2.Reliability
: The accuracy and repeatability of the test automation
3.Flexibility
: The ease of working with all the different kinds of automation test
ware
4.Efficiency
: The total cost related to the effort needed for the automation
5.Portability
: The ability of the automated test to run on different environments
6.Robustness
: The effectiveness of automation on an unstable or rapidly changing
system
7.Usability
: The xtent to which automation can be used by different types of
users
8.Return
on Investement : High automation ROI
9.Test
data: The ability to create test data is functionality, but how easy
and fast we can do it is a quality attribute.
10.Integration:
It should be easy and fast to integrate the test automation framework
with other tools.
- SQL query test:
Device:
Device_Id
|
Device_Name
|
Device_Cost
|
Location_Id
|
1
|
Device1
|
100
|
1
|
2
|
Device2
|
200
|
null
|
3
|
Device3
|
300
|
2
|
4
|
Device4
|
400
|
null
|
Asset:
- Asset_IdComputer_InfoAsset_DescriptionDevice_Id1A_Asset1Good12B_Asset1Ok43A_Asset2Bad24B_Asset2Good15A_Asset3Bad16B_Asset3Bad37A_Asset4Bad28B_Asset4Ok3
Location:
- Location_IdLocation_CodeLocation_StateLocation_City1Code1CTCity12Code2OHCity2
Write
a query
using above tables to retrieve “Device Name”, “Computer Info”
and “Location State” on the condition: “Computer_Info” starts
with “A” or Location_State is CT or no location.
ANSWER :
SELECT Device.Device_Id,
Asset.Computer_InfoAsset, Asset._Description, Location.Location_City
FROM ((Device
INNER JOIN Asset ON Device.Device_Id =
Asset.Device_Id)
INNER JOIN Location ON
Device.Location_Id = Location.Location_Id) Where Asset.Location_City
= "CT"
RESULT :
--------
Number of Records: 3
Device_Id Computer_InfoAsset _Description Location_City
1 A_Asset1 Good CT
1 B_Asset2 Good CT
1 A_Asset3 Good CT
Thank
you and Good Luck!!
No comments:
Post a Comment