0

I want to click on the href link as per attached image, And I've tried the below code but seems like it's not working. Please help me.

.....

driver.findElement(By.xpath("//a[@href='Careers']")).click();

............

Here is HTML content for Div tag... ..............

    <div class="logo">
        <img src="/ui/healthcare/assets/images/core/ascension_logo_white.svg" alt="Ascension">
    </div>


    <ul class="list-group">
            <li>
                <h4>Get Involved</h4>
                <ul class="link-list">
                            <li><a href="/Careers">Careers</a></li>
                            <li><a href="/Events">Classes and Events</a></li>

........................

.....enter image description here

enter image description here

1 Answer 1

1

Try this below xpath

 driver.get("https://healthcare.ascension.org/"); 
JavascriptExecutor js = ((JavascriptExecutor) driver); 
js.executeScript("window.scrollTo(0, document.body.scrollHeight)"); 
JavascriptExecutor executor = (JavascriptExecutor) driver; 
executor.executeScript("arguments[0].click();",driver.findElement(By.xpath("//a[@href='/Careers']")));
Sign up to request clarification or add additional context in comments.

4 Comments

It's not working, It's showing 'Element is not displayed'
if it is not working check the if there any iframe if it is you have to switch to iframe first.
for above code, It's showing the time out error - Expected condition failed: waiting for element to be clickable: By.xpath: //a[text()[contains(.,'Careers')]] (tried for 30 second(s) with 500 milliseconds interval)

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.