• Slider Banner

    Prepare for

    Technical Interview

    Over .1 Million+ Interview Questions for different profiles

    Read More
  • Slider Banner

    Join the

    Programming World

    Learn about top programming languages, tools and frameworks.

    Read More
  • Slider Banner

    Prepare with

    Certification MCQ

    Practice for certification from 1000+ multiple choice questions.

    Read More

Simple Rules for Copywriting

Rules for Copy writing 

Here are some of the rules that should be followed while creating the copy for organic or social media platforms:

1. Know Your Audience
There should be background research of audience and copy should be written in such a way that you are the audience who would be reading it.

2. Finding Your Unique Selling proposition
This is why your product or service is great. Way you do sell the things. It should have some unique proposition compared to the competitor that why your product is better in market.


3.Establish your Objective
Whenever you start writing make sure you understand your objective It is just to describe your product/ service or is it to go someone on email list etc. So copy should be direct, concise and straight forward.

4. Use a compelling subject line
Having a creek subject line is very important. Avoid weasel words like maybe, perhaps, however etc.

5.  Use the present tense
Because using in the past tense it goes passive . People take actions what is happening in present . Future tense might be a good practice but for sales page it should always on present tense.

6. Include customer quotes and testimonials
It is an easy and best way to attract new customers.Using reviews in copy is an advantage to get attention.

7. Keep it clean and concise
No big paragraphs should be used. Use your padding, italic words etc to appear it different.

8. Make it Pretty
Use images, videos/ visuals should match with your product. High quality visuals should be used.


 

What is the significance of testng.xml?

Since Selenium does not support report generation and test case management, we use TestNG framework with Selenium. TestNG is much more advanced than JUnit, and it makes implementing annotations easy. That is the reason TestNG framewrok is used with Selenium WebDriver.

But have you wondered where to define the test suites and grouping of test classes in TestNG?

It is by taking instructions from the testng.xml file. We cannot define a test suite in testing source code, instead it is represented in an XML file, because suite is the feature of execution. The test suite is basically a collection of test cases.

So for executing the test cases in a suite, i.e a group of test cases, you have to create a testng.xml file which contains the name of all the classes and methods that you want to execute as a part of that execution flow.

Other advantages of using testng.xml file are:

  • It allows execution of multiple test cases from multiple classes
  • It allows parallel execution
  • It allows execution of test cases in groups, where a single test can belong to multiple groups

Which technique should you consider using throughout the Selenium script if there is neither frame id nor frame name?

If neither frame name nor frame id is available, then we can use frame by index.

Let’s say, that there are 3 frames in a web page and if none of them have frame name and frame id, then we can still select those frames by using frame (zero-based) index attribute. Each frame will have an index number. The first frame would be at index 0, the second at index 1 and the third at index 2. Once the frame has been selected, all subsequent calls on the WebDriver interface will be made to that frame.

Example:

driver.switchTo().frame(1);

Explain how can you find broken links in a page using Selenium WebDriver?

The interviewer can provide a situation where in there are few links in a web page, and you have to verify which of those links are working and how many are not working (broken).

Since you need to verify the working of every link, the workaround is that, you need to send http requests to all of the links on the web page and analyze the response. Whenever you use driver.get() method to navigate to a URL, it will respond with a status of 200 – OK. 200 – OK denotes that the link is working and it has been obtained. If any other status is obtained, then it is an indication that the link is broken.

First, we have to use the anchor tags <a> to determine the different hyperlinks on the web page. For each <a> tag, we can use the attribute ‘href’ value to obtain the hyperlinks and then analyze the response received for each hyperlink when used in driver.get() method.

Explain how you will login into any site if it is showing any authentication popup for username and password using Selenium WebDriver?

If its Window popup then we have to use Robot Class or AutoIT. For Web Based popup, we need to use the explicit command and verify if the alert is actually present. Only if the alert is present, we need to pass the username and password credentials. The sample code for using the explicit wait command and verifying the alert is below:

WebDriverWait wait = new WebDriverWait(driver, 10); 
Alert alert = wait.until(ExpectedConditions.alertIsPresent()); 
alert.authenticateUsing(new UserAndPassword(**username**, **password**))

Can we enter text without using sendKeys() in Selenium WebDriver?

Yes. We can enter/send text without using sendKeys() method. We can do it using JavaScriptExecutor.

Using DOM method of, identification of an element, we can go to that particular document and then get the element by its ID (here username) and then send the text by value. Look at the sample code below:

JavascriptExecutor js = (JavascriptExecutor) driver;
js.executeScript("document.getElementById("username").value=myusername");

How to switch to a new window (new tab) which opens up after you click on a link using Selenium WebDriver?

If you click on a link in a web page, then for changing the WebDriver’s focus/ reference to the new window we need to use the switchTo() command. Look at the below example to switch to a new window:

String handle = driver.getWindowHandle();

//get the name of all the windows that were initiated by the WebDriver
for (String handle : driver.getWindowHandles()) 
{
    driver.switchTo().window(handle);
}

How to set the size of browser window using Selenium?

To maximize the size of browser window, you can use the following piece of code: 

driver.manage().window().maximize(); 

To resize the current window to a particular dimension, you can use the setSize() method. Check out the below piece of code:

System.out.println(driver.manage().window().getSize());
Dimension d = new Dimension(500, 600);
driver.manage().window().setSize(d);

To set the window to a particular size, use window.resizeTo() method. Check the below piece of code:

((JavascriptExecutor)driver).executeScript("window.resizeTo(1024, 768);");

How to send ALT/SHIFT/CONTROL key in Selenium WebDriver?

When we generally use ALT/SHIFT/CONTROL keys, we hold onto those keys and click other buttons to achieve the special functionality. So it is not enough just to specify keys. ALT or keys. SHIFT or keys. CONTROL functions.

For the purpose of holding onto these keys while subsequent keys are pressed, we need to define two more methods:  and 


keyDown(modifier_key)

Parameters: Modifier_key (keys.ALT or Keys.SHIFT or Keys.CONTROL)
Purpose: Performs a modifier key press and does not release the modifier key. Subsequent interactions may assume it's kept pressed.

keyUp(modifier_key)

Parameters: Modifier_key (keys.ALT or Keys.SHIFT or Keys.CONTROL)
Purpose: Performs a key release.

Hence with a combination of these two methods, we can capture the special function of a particular key.

Example

public static void main(String[] args)
{
    String baseUrl = "";
    WebDriver driver = new FirefoxDriver();
    
    driver.get("baseUrl");
    WebElement txtUserName = driver.findElement(By.id(“Email”);

    Actions builder = new Actions(driver);
    
    Action seriesOfActions = builder
    .moveToElement(txtUerName)
    .click()
    .keyDown(txtUserName, Keys.SHIFT)
    .sendKeys(txtUserName, “hello”)
    .keyUp(txtUserName, Keys.SHIFT)
    .doubleClick(txtUserName);
    .contextClick();
    .build();
    seriesOfActions.perform();
}

How can you fetch an attribute from an element? How to retrieve typed text from a textbox in Selenium?

We can fetch the attribute of an element by using the getAttribute() method.

Sample code:

WebElement eLogin = driver.findElement(By.name("Login");
String LoginClassName = eLogin.getAttribute("class");

Here, we are finding the web page's login button named "Login". Once that element is found, getAttribute() can be used to retrieve any attribute value of that element and it can be stored it in string format. In my example, We have retrieved "class" attribute and stored it in LoginClassName.

Similarly, to retrieve some text from any textbox, we can use getText() method. In the below piece of code I have retrieved the text typed in the "Login" element.

WebElement eLogin = driver.findElement(By.name("Login");
String LoginText = Login.getText ();
Subscribe to