Caused by: org.openqa.selenium.InvalidSelectorException: invalid selector: An invalid or illegal selector was specified

You are seeing...

org.openqa.selenium.InvalidSelectorException: invalid selector: An invalid or illegal selector was specified

...as the Locator Strategy you have used is a qualified xpath however within your code trials you considered it as a css-selectors.

Further, as per your code trials assuming the element to be a button element with value of id attribute as source-lp.select-lp.button, you can use a relative locator and you can use either of the Locator Strategies:

  • xpath:

    //button[@id="source-lp.select-lp.button"]
    
  • cssSelector:

    button[id="source-lp.select-lp.button"]
    

Ideally, to click() on any clickable element you need to induce WebDriverWait for the elementToBeClickable() and you can use either of the following Locator Strategies:

  • cssSelector:

    new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.cssSelector("button[id="source-lp.select-lp.button"]"))).click();
    
  • xpath:

    new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.xpath("//button[@id="source-lp.select-lp.button"]"))).click();
    

Update

For the element within parent1:

new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.xpath("//parent1//button[@id="source-lp.select-lp.button"]"))).click();

For the element within parent2:

new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.xpath("//parent2//button[@id="source-lp.select-lp.button"]"))).click();