私のプログラムがindeed.caにログインするようにしたいのですが(これは正しいユーザーの資格情報を入力している限り動作します)、特定のジョブの投稿最初のオレンジの適用ボタン(作業中)をクリックすると、モーダルがポップアップします。Java - Selenium Firefox Driver - モーダルで特定のボタンをクリックできません
次に、表示されるモーダルの青色の適用ボタンをクリックします。これは動作していません。私はプログラムのこの部分で私の試みをコメントアウトしました。
ご協力いただければ幸いです。
import java.io.IOException;
import org.openqa.selenium.By;
import org.openqa.selenium.firefox.FirefoxDriver;
public class Testing {
public static void main(String[] args) throws IOException {
//enter location of gecko driver
System.setProperty("webdriver.gecko.driver", "C:\\Users\\Padoga\\Documents\\geckodriver-v0.18.0-win64\\geckodriver.exe");
FirefoxDriver driver = new FirefoxDriver();
//login works correctly (given that you use proper credentials)
driver.get("https://secure.indeed.com/account/login?service=my&hl=en_CA&co=CA");
driver.findElement(By.xpath("//*[@id=\"signin_email\"]")).sendKeys("[email protected]");
driver.findElement(By.xpath("//*[@id=\"signin_password\"]")).sendKeys("enterPassword");
driver.findElement(By.xpath("//*[@id=\"loginform\"]/button")).click();
//once logged in navigate to specific job
driver.navigate().to("https://ca.indeed.com/cmp/KGHM-International-Ltd./jobs/Financial-Analyst-7a08f1634e7d5c5c");
//clicking on first apply button(orange button) works correctly
Thread.sleep(3000);
driver.findElement(By.xpath("//*[@id=\"apply-state-picker-container\"]/div[1]/span[1]")).click();
//below not working, trying to click on apply button(blue apply button) in popup modal
//I've tried so many different xpaths and ids none seem to be triggering the apply button in modal
Thread.sleep(3000);
driver.switchTo().frame("indeedapply-modal-preload-iframe");
driver.findElement(By.id("apply")).click();
}
}
ここにさまざまなhtml/javascriptがありますか?私が をクリックしようとしていた、つまり、By.id、By.xpath、またはBy.classNameとして使用されているものはありません。 ページソースを検査するとき、以下のコードは表示されません。ボタンボタンを適用オレンジをクリックした後にポップアップし、モーダルで、私は以下のコードを参照ください:
<div class="button_outter" id="apply-div">
<div class="button_inner">
<input class="button_content" id="apply" type="submit" name="apply" value="Apply">
</div>
</div>
暗黙の待機を追加して同じコードを試すことができますか? –
私はしばらく前に、問題を修正しなかった、// WebDriverWait wait = new WebDriverWait(driver、20); // WebElement要素= wait.until(ExpectedConditions.presenceOfElementLocated(By.id( "apply")))); – Padoga
おすすめのサンターですか? – Padoga