0

I can Login successfully but There is button "Start new booking" but my script doesn't click that button.

 import org.openqa.selenium.JavascriptExecutor;
 import org.openqa.selenium.WebDriver;
 import org.openqa.selenium.chrome.ChromeDriver;
 import com.paulhammant.ngwebdriver.ByAngular;
 import com.paulhammant.ngwebdriver.NgWebDriver;
 import org.openqa.selenium.support.ui.WebDriverWait;
 import org.openqa.selenium.support.ui.ExpectedConditions;
 import org.openqa.selenium.By;
 import org.openqa.selenium.WebElement;
 import org.openqa.selenium.support.ui.Wait;

 public class NewClass {

 public static void main(String[] args) throws InterruptedException {
    
    System.setProperty("webdriver.chrome.driver",
            "C:\\Users\\Hp\\Downloads\\chromedriver_win32\\chromedriver.exe");
        ChromeDriver driver = new ChromeDriver();
                    NgWebDriver ngWebDriver = new NgWebDriver(driver);
                    ngWebDriver.waitForAngularRequestsToFinish();
        driver.get("https://visa.vfsglobal.com/gbr/en/mlt/login");
                    driver.manage().window().maximize();
                    WebDriverWait wait = new WebDriverWait(driver, 30);
                    wait.until(ExpectedConditions.elementToBeClickable(By.id("onetrust-accept-btn-handler"))).click();
                    
                    // Login                     
                    
                    driver.findElement(By.id("mat-input-0")).sendKeys("*****@gmail.com");
                    driver.findElement(By.id("mat-input-1")).sendKeys("password");
                    
                    
                    driver.findElement(By.xpath("/html/body/app-root/div/app-login/section                /div/div/mat-card/form/button")).click();
                                 
                    driver.findElement(By.className("mat-button-wrapper")).click();
                                    
 }

}

Sample Image Here image

Help me How can i click that button. what is the problem , how can i solve?

1 Answer 1

1

Try those line . actually working for me

Thread.sleep(10000);

driver.findElement(By.xpath("/html/body/app-root/div/app-dashboard/section/div/div[2]/button")).click();
Sign up to request clarification or add additional context in comments.

3 Comments

welcome. Keep posting nice problem.
without html code, how can you provide xpath ?
there is website link, inside driver.get(); go to link and inspect you will get xpath code

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.