我可以成功登錄,但有“開始新預訂”按鈕,但我的腳本沒有點擊該按鈕。
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();
}
}
示例圖片這里的圖片
幫幫我 我怎樣才能點擊那個按鈕。是什么問題,我該如何解決?
uj5u.com熱心網友回復:
試試那些行。實際上為我作業
Thread.sleep(10000);
driver.findElement(By.xpath("/html/body/app-root/div/app-dashboard/section/div/div[2]/button")).click();
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/331707.html
