2

I'm trying to automate a customer journey in our application using selenium java. I have a problem with click() method (Chrome browser only).

Scenario: User adds items to cart, select payment method Google Pay and click on proceed to Payment button. On button click user should see sign in to Google child window.

Problem statement: My script successfully find the element 'proceed to pay' button and verify it is enabled and then click on the button. But it doesn't open up the child window. I tried with selenium click(), JavascriptExcutor click(), Keyboard enter and Mouse actions. But nothing works. Surprisingly If I do a manual click on the proceed to pay button in the same automation session it open up Sign in to google child window.

Same script works in other browsers, able to click and see child window of (Google Payment method) Selenium: 4.3.0 Chrome: 104.0.5112.48 & 103 102 as well

My Application HTML : enter image description here

**Code : ** I have tried all the possible options as below. There are no frames

    String payMethod = "GooglePay ";
    if(clickPayMethodV2(payMethod)) {
        clickElement(agreeCheckBox, "Agree Terms Check box");
        Assert.assertTrue(isElemenEnbaledClickable(ProceedToSecurePay, 4), "ProceedToSecurePay button is disabled for PayPal");
        boolean status =    isElemenEnbaledClickable(ProceedToSecurePay, 5);
            JavascriptExecutor js = (JavascriptExecutor) driver;    
            //js.executeScript("arguments[0].scrollIntoView();", element);  
            //Thread.sleep(1000);   
            driver.findElement(By.cssSelector("srgc2-secure-payment > form")).click();
            ProceedToSecurePay = driver.findElement(By.xpath("//button[contains(.,'Proceed to secure payment')]"));
            js.executeScript("arguments[0].focus;", ProceedToSecurePay);
            js.executeScript("arguments[0].click();", ProceedToSecurePay);
            clickElement(ProceedToSecurePay, "ProceedToSecurePay");
            
            js.executeScript("var ele = arguments[0];ele.addEventListener('click', function() {ele.setAttribute('automationTrack','true');});",ProceedToSecurePay);
            ProceedToSecurePay.click();
            System.out.println(ProceedToSecurePay.getAttribute("automationTrack")); 
            //System.out.println(ProceedToSecurePay.getShadowRoot().toString());
            click(ProceedToSecurePay, "Proceed To SecurePay button");
        
        
        clickElementJS(ProceedToSecurePay, "ProceedToSecurePay");
        }
    else {
        logInfoExtent("Failed to click on Payment method: "+payMethod +"in checkout Step 3. PAYMENT");
        throw new TestException("Failed to select Payment method: "+payMethod +"in checkout Step 3. PAYMENT");
    }

    
    Actions action=new Actions(driver);
    action.moveToElement(ProceedToSecurePay).perform();
    action.moveToElement(ProceedToSecurePay).click().perform();
    
    ProceedToSecurePay.submit();
    ProceedToSecurePay.sendKeys(Keys.ENTER);

enter image description here

Your help on this issue would be greatly appreciated.

  • Have you tried double click? – Nandan A Jul 21 '22 at 10:30
  • @NandanA I have tried double click() as well. but no luck. – Automation User Jul 22 '22 at 05:39
  • I just tried click() method in console manually, It opens up a child window . below statement. `document.getElementsByClassName("btn btn-large btn-solid-secondary mx-100")[0].click()`. but when I try to execute the same statement through selenium it does nothing. Here is the code I tried in selenium-java `JavascriptExecutor jsEx = (JavascriptExecutor) driver; jsEx.executeScript("document.getElementsByClassName('btn btn-large btn-solid-secondary mx-100')[0].click()");` – Automation User Jul 22 '22 at 05:41
  • Please share your findings, if resolved by now. You may raise this issue with Selenium in github issues. – Ahamed Abdul Rahman Jun 25 '23 at 05:08
  • Did you check interacting with child span or parent div? – Ahamed Abdul Rahman Jun 25 '23 at 05:17

0 Answers0