I worked in selenium for 3 months. I had written some code. In my company I am the only tester. Nobody knows about the testing. But I couldn't find a solution for is it my code is correct or not. I tested the login module anybody please correct my code. A senior tester told me that the test script are fine. He asked me that What are you testing with this? Actually I want to find a solution for this. what should I do? What I will test for my project? Is there any If condition statement I miss? Here is my code..

package QberLogin;
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.support.ui.Select;

public class AdminLogin 

    public static void main(String[] args) throws Exception 

        System.setProperty("webdriver.firefox.marionette", "pathToGeckodriver");
        FirefoxDriver driver = new FirefoxDriver();
        WebElement element = driver.findElement(By.name("username"));

            Actions action = new Actions(driver); 

           element= driver.findElement(By.linkText("Admin"));
           element= driver.findElement(By.linkText("Clients"));
           element= driver.findElement(By.xpath("//*[@id='search-container']/a/i"));
           element.sendKeys("Dubai Bank");
           Select stat=new Select(driver.findElement(By.id("status")));

          element= driver.findElement(By.linkText("Hello Sony George"));

           element= driver.findElement(By.linkText("Logout"));




closed as unclear what you're asking by NarendraC, Ivan Gerasimenko, Kate Paulk, IAmMilinPatel, dzieciou Sep 22 '16 at 12:47

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • where you stuck? Pls add details – NarendraC Sep 22 '16 at 6:16
  • 1
    @NarendraC ..Hai I edited. – user21268 Sep 22 '16 at 6:31

After a quick review of the code I come with the following comments:

The flow of your test should look something like this:

  • Arrange
  • Act
  • Assert

Using the AAA pattern will make it more clear what is part of the test and what is not. Read about AAA here. I always add a comment to show where which part of the test starts.

Alternatively describe your test with

  • Given
  • When
  • Then

Your test name/description could be come GivenIAmLoggedIn_WhenIClickSomeButtons_SomethingHappensThatIVerfify. Read more here.

Leading to this test format:

 public void GivenInputABC_WhenIReverseInput_ThenResultIsCBA() {
    // Arrange
    String input = "abc";
    // Act      
    String result = Util.reverse(input);
    // Assert
    assertEquals("cba", result);

The next step to make your test more readable, understandable and maintainable is to wrap it in the Page Object Model. Read more here: http://toolsqa.com/selenium-webdriver/page-object-model/

  • @Niets van Reijmersdai . Thanks.. Is it companies are now using Page object model ? or Which framwork are now the companies are using ? I want to implement it in my company. It will also helpful for me and upcoming new joinees.. – user21268 Sep 22 '16 at 9:10
  • 2
    Page object model is not a framework, but it is the leading GUI test structuring pattern. I cannot advice a Java testing framework since I do not develop in Java anymore for some years. What I can advice is to write automated test in the same language as the application is developed in, because it makes it easier to get help from developers or for developers to write and maintain tests themselves too. Each language has its own popular testing tools and frameworks. Goodluck. – Niels van Reijmersdal Sep 22 '16 at 10:14