Trying to make a shortcut on Apple iPhone to login to website using JavaScript in the shortcut.

The html of the login page is:

            <div class="loginFormContainer">
                <div class="col-xs-10 col-xs-offset-1 col-sm-6 col-sm-offset-0 col-md-5 col-lg-4 loginPanel">
                    <div id="loginFormContainer" class="col-sm-offset-1">
                        <form id="loginForm" action="/processWebLogin" method="POST" autocomplete="off">
                            <div class="form-group">
                                <label for="username">User ID</label>
                                <input id="username" name="username" type="text" autocomplete="off" class="form-control loginInput" placeholder="Your User ID" value="">

                            <div class="form-group">
                                <label for="password">Web Login Password</label>
                                <input id="password" name="password" type="password" autocomplete="off" class="form-control loginInput" placeholder="Your Password">

                            <div class="topBottomMargin text-right">
                                <button class="btn btn-sm btn-orange-wft" title="Sign In">Sign In</button>
                            <input type="hidden" name="CSRFToken" value="4e458174-202b-4ea8-a625-3fc358a0b77a">

                <div class="col-xs-10 col-xs-offset-1 col-sm-5 col-sm-offset-0 col-md-6 col-lg-5 logoutPanel">
                    <div class="clearfix col-sm-offset-1">

Unable to trigger click or find submit button with only a “.title” not “.Id”

The following is the JavaScript I’m using in the shortcut:

var result = [];

var emailTextBox = document.getElementById("username");
emailTextBox.value = "myUserName";

var pwTextBox = document.getElementById("password");
pwTextBox.value = "myPassword";

var submitBtn = document.getElementById("Sign In").title;

// Call completion to finish

1 Answer 1

var submitBtn = document.getElementById("Sign In").title;

This is asking for the title of the element with ID "Sign In", but there’s no such element. (Even if there was an element with that ID, getting its title is just a string so you can't click it.)

Use a query selector for more powerful element selection.

var submitBtn = document.querySelector("button[title=\"Sign In\"]");

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .