2017-11-21 12 views
0

私はseleniumとjavaから始めています。私はこのhttps://www.argenta.nl/hypotheek/hypotheek-berekenen#/formulierウェブサイトを試しています。私は自分の仕事(dienstverband)を選択し、所得(bruto jaarinkomen)の金額を記入し、 'ga verder'ボタンをクリックしなければならない時点で固まっています。必須のテキストフィールドはsendkeysで埋められません

フィールド収益が満たされている場合は、ボタン 'ga verder'が有効になります。私のスクリプトでは、私はこのコード行では、このフィールド「収益」に記入:。

driver.findElement(By.name("orientationCalculatorCtrlCalculatorMainApplicantIncomePermanentThisYearIncome")).sendKeys("51000"); 

しかし、私はボタンをクリックすると「GAのverder'nothingが満たされた(システムが赤通知を与える)私が送って思いましたキーは、必要なテキストフィールドを入力するための適切なオプションでした。誰が私を助けることができます。

私の全体にTestScript:

System.setProperty("webdriver.chrome.driver", "C:\\Users\\Esmee\\IdeaProjects\\seleniumTestArgenta\\src\\drivers\\chromedriver.exe"); 
    WebDriver driver = new ChromeDriver(); 
    driver.get("http://www.argenta.nl"); 
    WebElement element; 

    //opening orientation calculator (code akkoord) 
    driver.findElement(By.xpath("/html/body/div/header/div/div/div[3]/ul/li[2]/a")).click(); 
    driver.findElement(By.xpath("/html/body/div/header/div/div/div[3]/ul/li[2]/div/div/div/a[2]/div[1]")).click(); 
    driver.findElement(By.xpath("/html/body/div/div[2]/article[1]/div/div/div/div[2]/div/div/a")).click(); 

    //wait for 10 seconds 
    driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); 

    //clicking on button 'ga verder'gives a notification (Code Akkoord) 
    driver.findElement(By.xpath("/html/body/div/div[2]/article[1]/div/form/div/ui-view[1]/div/div/div[2]/div/button")).click(); 

    //Uw situatie, select radiobutton no (= value 1), then push button 'ga verder'. 

    element = driver.findElement(By.cssSelector("input[value='1']")); 
    JavascriptExecutor executor = (JavascriptExecutor)driver; 
    executor.executeScript("arguments[0].click();", element); 

    driver.findElement(By.xpath("/html/body/div/div[2]/article[1]/div/form/div/ui-view[1]/div/div/div[2]/div/button")).click(); 

    //wait for page to load, select income, fill in 51000 
    driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); 
    driver.findElement(By.xpath("//*[@id=\"orientationCalculatorCtrlCalculatorMainApplicantIncomeVariant\"]")); 

    Select dropdown = new Select(driver.findElement(By.id("orientationCalculatorCtrlCalculatorMainApplicantIncomeVariant"))); 
    dropdown.selectByVisibleText("Vast contract"); 
    driver.findElement(By.name("orientationCalculatorCtrlCalculatorMainApplicantIncomePermanentThisYearIncome")).sendKeys("51000"); 

    //pushing button 'ga verder' (system verifies input) 
    element = driver.findElement(By.xpath("/html/body/div/div[2]/article[1]/div/form/div/ui-view[2]/div/div/div[2]/div/button")); 
    executor = (JavascriptExecutor) driver; 
    executor.executeScript("arguments[0].click();",element); 

答えて

0

は、あなたが試みることができる:

WebElement yourElement = driver.findElement(By.xpath("nameOfTheElementHere")); 
Actions act = new Actions(driver); 
act.moveToElement(yourElement).click(); 
act.sendKeys("51000"); 
act.build().perform(); 

または:

WebElement yourElement = driver.findElement(By.xpath("xpathHere")); 
JavascriptExecutor executor = (JavascriptExecutor)driver; 
executor.executeScript("arguments[0].click();", yourElement); 

それとも単に待機の問題である可能性があり、その場合には

WebElement yourElement = driver.findElement(By.xpath("xpathHere")); 
WebDriverWait wait = new WebDriverWait(driver, 10); 
wait.until(ExpectedConditions.elementToBeClickable(yourElement)).click(); 
関連する問題