Code Monkey home page Code Monkey logo

cuke3-migrate-parametertype's Introduction

Hello World! ๐Ÿ‘‹

  • Iโ€™m currently learning Playwright
  • Ask me about Selenium, Cucumber, Rest Assured, Extent Reports
  • Looking for automation testing jobs or consulting opportunities
  • Visit and leave a comment on my tech blog
  • Reach me at my email [[email protected]]

cuke3-migrate-parametertype's People

Contributors

grass-hopper-moc avatar grasshopper7 avatar

Stargazers

 avatar

Watchers

 avatar

cuke3-migrate-parametertype's Issues

Convert DataTable to custom object instead of List

Description:
Convert a datatable with 1 row only from the feature file to a custom object instead of a list of that object.

Code:

// Feature
Scenario: Scan Barcode
	Given I Am At The Login Page
	When I Log In As Valid User
		| group | username | password |
		| gpao  | svgpao1  | ****     |

// Stepdef
@When("I Log In As Valid User")
public void I_Log_In_As_Valid_User(DataTable dataTable) throws Throwable {
	List<User> users = dataTable.asList(User.class);
	User user = users.get(0);
	Selenium.enterText(driver, user.getUsername(), "username");
	Selenium.enterText(driver, user.getPassword(), "password");
	Selenium.clickElement(driver, "sign.in");
	LOGGER.debug("User Group=" + user.getGroup());
}

// Configurer
public class DataTableConfigurer implements TypeRegistryConfigurer {

	@Override
	public Locale locale() {
		return Locale.ENGLISH;
	}

	@Override
	public void configureTypeRegistry(TypeRegistry registry) {
		registry.defineDataTableType(new DataTableType(User.class, new TableEntryTransformer<User>() {
			@Override
			public User transform(Map<String, String> entry) {
				return new User(entry.get("group"), entry.get("username"), entry.get("password"));
			}
		}));
	}

}

// User
public class User {

	private String group = null;
	private String username = null;
	private String password = null;

	public User() {

	}

	public User(String group, String username, String password) {
		this.group = group;
		this.username = username;
		this.password = password;
	}
	
	// Getters and setters
}

Above works, but since I do not really expect any additional rows to the datatable in the feature file, I prefer it to be a User object instead of List<User>.

Any available documentation for that? Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.