1

I am automating a scenario. I am using selenium with page object. Here some text fields doesn't enter the value.. There is no error in the program no error in console. locators are correctly mentioned. but still I couldn't get why should not automate the page ?

enter image description here

Html codes :

    Name text :    <input type="text" id="name" value="" name="name"
     class="form-control" />
               <span class="text-danger"></span>

    Name (language) : <input type="text" id="name_locale" value="" name="name_locale" class="form-control">

prefix : <input type="text" id="prefix" value="" name="prefix" class="form-control">

Token starts :  <input type="text" id="token_starts" value="" name="token_starts" class="form-control">

Token ends :  <input type="text" id="token_ends" value="" name="token_ends" class="form-control">

subcategory

package pageobjects;

import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.How;
import org.openqa.selenium.support.ui.Select;

/**
 * Created by naveen on 5/12/16.
 */
public class subcategoryPage {
    @FindBy(how= How.LINK_TEXT,using ="App")
    WebElement app;
    @FindBy(how =How.LINK_TEXT,using= "Sub Category")
    WebElement sub;
    @FindBy(how =How.XPATH,using = "//*[@id=\'search-container\']/a/i")
    WebElement addsub;
     @FindBy(how =How.NAME, using ="name")
    WebElement name;
    @FindBy(how =How.ID,using ="name_locale")
    WebElement name_local;
    @FindBy(how=How.ID,using ="category")
    WebElement category_dropdown;
    @FindBy(how =How.ID, using= "client")
    WebElement client_dropdown;
    @FindBy(how=How.ID,using ="prefix")
    WebElement prefix;
    @FindBy(how =How.ID, using ="token_starts")
    WebElement tokenstart;
    @FindBy(how =How.ID,using ="token_ends")
    WebElement tokenends;
    @FindBy(how =How.ID, using ="token_avg_speed")
    WebElement token_avg;
    @FindBy(how= How.CLASS_NAME,using= "btn-primary")
    WebElement button;
    public void setApp(){app.click();}
    public void setCategory(){sub.click();}
    public void setAddcategory(){addsub.click();}
    public void setName(String nam){name.sendKeys();}
    public void setName_local(String nam_loc){name_local.sendKeys();}
    public void setCategory_dropdown(String ca) {
        Select cat = new Select(category_dropdown);
        cat.selectByVisibleText(ca);
    }
    public void select_client(String cli)
    {
        Select client_id=new Select(client_dropdown);
        client_id.selectByVisibleText(cli);
    }
    public void setPrefix(String pre){prefix.sendKeys();}
    public void setTokenstart(String ts){tokenstart.sendKeys();}
    public void setTokenends(String te){tokenends.sendKeys();}
    public void setToken_avg(String tavg){token_avg.sendKeys();}
    public void setButton(){button.click();}
}

Test case

package subcategory;

import org.testng.Assert;
import org.testng.annotations.BeforeSuite;
import org.testng.annotations.Test;
import pageobjects.HomePage;
import pageobjects.ManageMenu;
import pageobjects.subcategoryPage;
import steps.LoginSteps;
import steps.managesteps;
import steps.subcategorysteps;
import util.DriverManager;

/**
 * Created by naveen on 6/12/16.
 */
public class subcategoryTest extends DriverManager {
    @BeforeSuite
    public void initDriver() {
        //Arrange
        HomePage page = new LoginSteps().Login("geosony", "123456789");
    }

    @Test
    public void verifyValidLoginWithDataProvider() throws Exception {
        //Act
        subcategorysteps log = new subcategorysteps();
        subcategoryPage ex = log.Login("Loan ","English","Loan","Bur Dubai","LLA","123","321","5");

        //Assert
        Assert.assertTrue(driver.getPageSource().contains("Hello Sony George"));

    }
}
  • @Niels van Reijmersdal Do you know the solution ? – user21268 Dec 6 '16 at 9:50
  • Can you tell do you call page object class single time in your code? – Sagar007 Dec 6 '16 at 11:04
  • @Sagar007 Here i am not copy the code. because there is no error in my code.. other scenarios are working properly. locators are properly mentioned. actually doesn't enter the values in any text box. – user21268 Dec 6 '16 at 11:21
  • please provide one small sample to add in that element and also the element – Sagar007 Dec 6 '16 at 11:42
  • @Sagar007 ya sure don't go – user21268 Dec 6 '16 at 11:43
1

Please check following line in class subcategoryPage:

public void setName(String nam){name.sendKeys();}

Here as mentioned blank data is entered so Please change this line as per under :

public void setName(String nam){name.sendKeys(nam);}

And same as other elements.

Please Let me know If any query.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy