Adım-1:Maven Projesi oluşturma

Adım-2:pom.xml dosyasına projemizde kullanacağımız depenciesleri ekleyelim. Bizim projemizde kullanılacak dependiciesler;

Selenium-java

Webdriver Manager

TestNG

poi

poi-ooxml

Adım-3:@DataProvide bir TestNG annotations.

Adım-4:test/java class altında bir package,package içinde de DataProvider First Class isimli java class ımızı oluşturalım.Class içeriği aşağıdaki gibi olmalıdır.

public class DataProviderFirstClass {

@DataProvider
public static Object [][] dataProviderMethod(){
String [][] searchWord={
{“java”}, // if there is two variable in here, in method you can use two parameter
{“python”},
{“csharp”}};

return searchWord;
}
@Test(dataProvider = “dataProviderMethod”)
public void searchGoogle(String word){ // if there is two variable in here, in method you can use two parameter
Driver.getDriver().get(“https://www.google.com.tr/”);
WebElement searchBox= Driver.getDriver().findElement(By.xpath(“//input[@name='q']"));
searchBox.sendKeys(word+ Keys.ENTER);
Assert.assertTrue(Driver.getDriver().getTitle().contains(word));

System.out.println(word+” ile alakalı “+Driver.getDriver().findElement(By.cssSelector(“div#result-stats”)).getText());

Driver.getDriver().navigate().back();
}

}

Not:Tüm projenin kodlarına https://github.com/zoomokul/POMproject adresinden ulaşabilirsiniz

--

--

We wrote two articles about cypress BDD approach, now we are writing third article about this topic.

Step-1: Firstly as you know we should create a folder and two files which are names;

thirdCucumber.js

thirdCucumber.feature

thirdCucumber

Step-2: now lets create feature file which named “thirdCucumber.feature”. As you can see, I use datatable this examples, and I search on google this words one by one.

Feature: Search

I want to search on google

Scenario: search on google

Given open google search page

And type

|language|

|java|

|python|

|csharp|

|sql|

|javascript|

Step-3:Lastly I create “step definition” file. Its content should be like that.

--

--