-1

I've tried several ways, but I just cannot seem to get Selenium to resolve to this HTML element on a page:

<button class="btn__primary--large from__button--floating" data-litms-control-urn="login-submit" aria-label="Sign in" type="submit">Sign in</button>

The value is null according to the DOM, and there are multiple submits on the page.

I have tried by.class, by.xpath. I don't know what code to include as the rest of it resolves, and it's a third party page.

I have tried findElement By.xpath, By.class (with the class names), byTagName with any of the text in the element, and byValue which didn't work as there wasn't one.

webDriver.manage().window().maximize();
webDriver.get("https://www.linkedin.com/login?fromSignIn=false&trk=guest_homepage-basic_nav-header-signin");
Thread.sleep(4000);
WebElement username = webDriver.findElement(By.name("session_key"));
WebElement password = webDriver.findElement(By.name("session_password"));
username.sendKeys("xxxxxx");
password.sendKeys("xxxxxx");
WebElement submit = webDriver.findElement(By.xpath("//input[@type='submit']"));
submit.click();
Mark Rotteveel
110k241 gold badges160 silver badges233 bronze badges
asked Jul 25, 2025 at 12:27
3
  • What exactly have you tried? Please include your code as a minimal reproducible example. Commented Jul 25, 2025 at 12:28
  • edited with requested Commented Jul 25, 2025 at 12:34
  • //input[@type='submit'] obviously won't work, as it isn't an input, but a button. Commented Jul 25, 2025 at 12:54

2 Answers 2

0

You can use this xpath: //*[@id="organic-div"]/form/div[4]/button

I got this by opening the developer tools and selecting the element in the Elements tab and then right click > Copy. And here you have all the options to query the element. You can try all of them or the above xpath.

Mark Rotteveel
110k241 gold badges160 silver badges233 bronze badges
answered Jul 25, 2025 at 12:44
Sign up to request clarification or add additional context in comments.

7 Comments

That worked! I was inspecting, but I didn't see this exact item. I shall endeavor to look for that on the next elements, thank you!
Are you a co-worker of the OP, because you can only have come to this answer with information not present in the question.
@MarkRotteveel The URL of the page is included in the question.
@InSync Questions need to be self-contained, that means that the relevant sources need to be in the question itself. If LinkedIn changes their code between the time it was posted and some reads it, it has become essentially meaningless. But you're right, I guess Prango did follow the link
@MarkRotteveel Yes you guessed right, I did use the link from the question. Also as Mark said, they can change their code and break the query, so use stable/unique selectors if available like ID or data- attributes. Glad it worked Robert, if it answered your question pls mark it as accepted :)
|
0

Use this xpath which is much more robust - //button[contains(text(),'Sign in')]

answered Aug 27, 2025 at 14:46

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.