I have a number of scripts, in which i want to scan a particular type of string, and replace dots in those strings alone. We are replacing our locator strategy from map to something else, so the variables have to be changed from having dots to having underscore
In the below, I want to change
driver.click(objectMap.getIdentifier(new.dropdown), "DropDown clicking");
TO
driver.click(new_dropdown, "DropDown clicking");
So 2 things :
- remove the text
objectMap.getIdentifier - Replace the enclosed string from having dots to underscore
If I try to use sed 's/./_/g' >> This will replace all the dots across, I want to replace only the dots which are enclosed within objectMap.getIdentifier.
Tried these sed commands, but not of much use :
sed -e 's/objectMap.getIdentifier("\(.*\).\(.*\)")/(\1_\2)/pg'
Example :
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
public class TestingScript {
public void createNewItems(String itemName){
driver.click(objectMap.getIdentifier(new.dropdown), "DropDown clicking");
driver.click((objectMap.getIdentifier("new.dropdown.notes.button"), "Note from template");
driver.click((getElement(objectMap.getIdentifier("modal.default.template").replace("$Template", "Default")), "Default", true);
driver.click((getElementByText(templateName), templateName);
driver.click(objectMap.getIdentifier(new.dropdown), "DropDown clicking");
driver.click((objectMap.getIdentifier("modal.create.button"), "Create");
}
}