I am using Python, Webdriver for my automatic test. My script is on the admin page of our website. I click the "Add Project" button and I enter the name of the project.
Project Name I enter the format LADEMO_IE_05/20/1515:11:38
This is the date and time at the end.
What I would like to do is use the regex that I would like to find in / and: and replace them with an underscore _
I developed a regex expression:
[0-9]{2}[/][0-9]{2}[/][0-9]{4}:[0-9]{2}[:][0-9]{2}
This finds 2 digits, then /followed by 2 digits, then /etc.
I would like to replace /and :on _.
Can I do this in Python using import? I need help with the syntax.
My method that returns the date:
def get_datetime_now(self):
dateTime_now = datetime.datetime.now().strftime("%x%X")
print dateTime_now
return dateTime_now
My code snippet for entering the project name in the text box:
project_name_textfield.send_keys('LADEMO_IE_' + self.get_datetime_now())
The output is, for example,
LADEMO_IE_05/20/1515:11:38
I would like Output to be:
LADEMO_IE_05_20_1515_11_38