Lambda expression in Selenium

How to use JAVA Lambda expression to select the value from drop down in selenium.

Let say you have a list and want to select a value from it.

<ul class = 'list'> 
 <li data-value="value1" class="option selection focus">Value1</li>
 <li data-value="value2" class="option selection focus">Value2</li> 
  <li data-value="value3" class="option selection focus">Value3</li> 
 <li data-value="value4" class="option selection focus">Value4</li> 

Below code can select the value from drop down as per the parameter passed in the method  

Public void selectValueFromDropDown(String SearchValue)
WebElement element = Driver.driver.findElements(By.xpath("//ul[@class='list']//li")).stream().
 filter(e-> e.getText().equalsIgnoreCase(SearchValue)).findFirst().get();;

CloudFormation template for EC2 and Security Group creation

Below template can be used to create EC2 instance and associate Security Group with the EC2 instance which enables SSH.

AWSTemplateFormatVersion : 2010-09-09
Description: Template to create an EC2 instance and enable SSH access to the instance
Description: Name of an existing EC2 KeyPair to enable SSH access to the instance
Type: 'AWS::EC2::KeyPair::KeyName'
ConstraintDescription: Provide the name of an existing SSH key pair Resources:
Type: 'AWS::EC2::Instance'
InstanceType: t2.micro
ImageId: ami-0f2176987ee50226e
- !Ref InstanceSecurityGroup
KeyName: !Ref KeyName
- Key: Name
Value: My First CF Instance
Type: 'AWS::EC2::SecurityGroup'
GroupDescription: Enable SSH access via port 22
IpProtocol: tcp
FromPort: 22
ToPort: 22
Description: The Instance ID
Value: !Ref MyEC2Instance

Save above file with .yml extension.

The only thing we need to change in the above template is ImageId: ami-0f2176987ee50226e .

Image IDs are based on the region. Login to your AWS account Go to your EC2 and Click Launch Instance. Copy Image ID as shown in image below and past it in the template.

Template is ready to create the stack.

In AWS console, Go to Services -> Manage & Governance -> CloudFormation

Click “Create New Stack” button.

Choose file from your location and Click Next

Enter Stack name and Select key pair from the drop down and click Next.

In the option page, Click Next

In the Review page, Click Create

Stack creation started.

Once the process completed. Go to EC2 page. You will see instance created with Security Group.