1

I want my program to log into indeed.ca (this is working, as long as you enter correct user credentials), navigate to a specific job posting(working), click on the first orange apply button(working), a modal pops up.

Then I want to click on the blue apply button in modal that appears. This is not working. I have commented out my attempt at this portion of the program.

Any help would be much appreciated.

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

 } 
}

And here is the various html / javascript? that I have been trying to click on i.e used as By.id, By.xpath, or By.className, none are working The below code does not show up when I inspect the page source, only when I inspect the blue apply button in the modal that pops up after clicking the orange apply button, do I see the below code:

<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>
10
  • Can you add some implicit wait and try the same code? Commented Aug 7, 2017 at 2:52
  • I tried that a while ago, didn't fix issue, // WebDriverWait wait = new WebDriverWait(driver, 20); // WebElement element = wait.until(ExpectedConditions.presenceOfElementLocated(By.id("apply"))); Commented Aug 7, 2017 at 4:36
  • any recommendations santhosh? Commented Aug 7, 2017 at 4:37
  • Consider updating the question with relevant HTML. Thanks Commented Aug 7, 2017 at 5:01
  • I am checking .. Commented Aug 7, 2017 at 5:03

3 Answers 3

1

I have tried using the switch to Iframe, but this is not working in this case. Can you check the below sendkeys approach after clicking the first apply button.

 Actions act = new Actions(driver);
 act.sendKeys(Keys.TAB, Keys.TAB, Keys.TAB, Keys.TAB, Keys.ENTER);

or

driver.findElement(By.xpath("//body")).sendKeys(Keys.TAB, Keys.TAB,Keys.TAB, Keys.TAB, Keys.ENTER);

Update: It seems, second recommendation actually worked for this case.

Hope this helps. Thanks.

Sign up to request clarification or add additional context in comments.

1 Comment

thanks so much Santhosh, your first recommendation doesn't work, but your second recommendation works great. I just edited your second solution, as you added an extra bracket at the end. Appreciate all your help. Padoga
1

You need to switch to the iframe firtst then call click() method on the Blue Apply button as follows:

    driver.switchTo().frame(driver.findElement(By.xpath("//iframe[contains(@src,'https://apply.indeed.com/indeedapply/resumeapply')]")));
    //perfrom other actions
    //finally click on Blue Apply button
    driver.findElement(By.xpath("//input[@id='apply']")).click();   

Comments

1

It seems the index order of the iframes is backwards, at least that's what it looks like to me. I was able to click the "Blue Apply Button" using the following java code:

driver.get("https://ca.indeed.com/cmp/KGHM-International-Ltd./jobs/Financial-Analyst-7a08f1634e7d5c5c");
wait = new WebDriverWait(driver, 10);
//on my screen I had to scroll down to the orange apply button
WebElement applyButton  = wait.until(ExpectedConditions.presenceOfElementLocated(By.className("indeed-apply-button")));
((JavascriptExecutor) driver).executeScript("arguments[0].scrollIntoView(true);", applyButton);
applyButton.click();
Thread.sleep(1000);
driver.switchTo().frame(1);
driver.switchTo().frame(0);
driver.findElement(By.id("applicant.name")).sendKeys("My First Name is");
driver.findElement(By.id("apply-div")).click();

3 Comments

Thanks smit9234, this solution works great, and is great way of switching frames, and finding / selecting actual elements in new frame. I was using firefox driver which I think doesn't need you to scroll down, or the Javascript Executor. Does your code assume someone is using HtmlUnitDriver?
I was testing it in chrome, which was throwing an "no element found" exception. Once I implemented the javascript executor it worked fine. Not sure what would happen using htmlunitdriver.
Hey smit9234, your code was working great, but as of a week ago I think Indeed.ca changed something and your code: driver.switchTo().frame(1); driver.switchTo().frame(0); no longer seems to work, any idea, how to fix.

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.