Writing a simple code using Fluentlenium for Selenium Java

In the last post we disscused how to write a 5s code with Fluentlenium for Selenium Java.

In this post, we will be writing code further more for some other controls like:

  • naviagte to url
  • click button
  • fill in a text box
  • getText in web element

Here is the complete code for above:

@Test
 public void bmi_calculator(){
 // Navigate to bmi calculator page
 goTo("http://www.calculator.net/bmi-calculator.html");
 
 //Click Metric tab
 find(By.xpath(".//a[.='Metric Units']")).click();
 // fill in age 
 fill("#cage").with("25");
 // select gender
 click("#csex1");
 // fill in height
 fill("#cheightmeter").with("172");
 // fill in weight
 fill("#ckg").with("76");
 //click calculate button
 click("input[value='Calculate']");
 
 // print out the result
 System.out.println("===========================");
 System.out.println(find(".rightresult").getText());

and here is outupt console:

===========================
Result

BMI = 25.69 kg/m2 (Overweight)
Normal BMI range: 18.5kg/m2 - 25 kg/m2
Normal BMI weight range for the height: 54.7kgs - 74.0 kgs
Ponderal Index: 14.94 kg/m3

 

 

Thanks for reading the post !!!

Please leave your comments and let me know if there is anything I should update in this post.

Thanks,
Ha Do

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.