簡體   English   中英

如何使用硒單擊角度應用程序按鈕

[英]How can I Click angular application button using selenium

我可以成功登錄,但有“開始新預訂”按鈕,但我的腳本沒有點擊該按鈕。

 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();
                                    
 }

}

示例圖片這里的圖片

幫幫我 我怎樣才能點擊那個按鈕。 是什么問題,我該如何解決?

試試那些行。 實際上為我工作

Thread.sleep(10000);

driver.findElement(By.xpath("/html/body/app-root/div/app-dashboard/section/div/div[2]/button")).click();

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM