Since you are running selenium, I am guessing you are using python for your scripts. If that is the case then boto3 is the way to go. https://boto3.readthedocs.io/en/latest/guide/ec2-example-managing-instances.html
With this you can easily check the current state and start it if it is off.
You will need to set up aws sdk keys http://docs.aws.amazon.com/sdk-for-java/v1/developer-guide/credentials.html
So something like this might work, you might need to make some changes:
import boto3
ec2 = boto3.resource('ec2')
instance = ec2.Instance('instance_id')
if instance.state['Name'] != u'running':
try:
ec2.start_instances(InstanceIds=[instance_id], DryRun=True)
except ClientError as e:
if 'DryRunOperation' not in str(e):
raise
try:
response = ec2.start_instances(InstanceIds=[instance_id], DryRun=False)
print(response)
except ClientError as e:
print(e)