0

I used this selenium code trying to select data in my web page the probleme i am facing is that even though i use the switch to a new frame the elements are still not found and i cant type in them since they dont exist . As you can see in the picture the #document doesnt exist even after the code got execute and i got the error i tried the solution to the question with the same title as mine but i didnt work i even added a wait for the element to be visabel but it never works. #document missing the paths you will find in my code are taken from this #document that only show after i refresh i know you will say that i should force a refresh i tried that but it didn't work even though the refresh happens the #document still doesnt show. My code :

WebElement ClkPaiementByCard = driver.findElement(By.id("payed-cart"));
            js.executeScript("arguments[0].click();", ClkPaiementByCard);
            driver.navigate().refresh();
            for (String handle : driver.getWindowHandles()) {
                driver.switchTo().window(handle);
            }
            new WebDriverWait(driver, Duration.ofSeconds(20)).until(ExpectedConditions.frameToBeAvailableAndSwitchToIt(By.xpath("//iframe[starts-with(@id, 'hipay-controller') and @data-hipay-id='hostedfield-iframe']")));
            WebElement ValidationCreation = wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//div[@id=\"root\"]/div/div/form/div/div/input[@name=\"cardnumber\"]")));
            WebElement CardNumber = driver.findElement(By.xpath(
                    "//div[@id=\"root\"]/div/div/form/div/div/input[@name=\"cardnumber\"]"));
            CardNumber.clear();
            CardNumber.sendKeys("");
            WebElement ExpDate = driver.findElement(By.xpath(
                    "//div[@id=\"root\"]/div/div/input[@name=\"cc-exp\"]"));
            ExpDate.clear();
            ExpDate.sendKeys("");
            WebElement CVC = driver.findElement(By.xpath(
                    "//div[@id=\"root\"]/div/div/input[@name=\"cvc\"]"));
            CVC.clear();
            CVC.sendKeys("");           
            WebElement SubmitPaiement = driver.findElement(By.id("submit-button"));
            js.executeScript("arguments[0].click();", SubmitPaiement);

Can any one tell me what i am doing wrong ?

0 Answers0