I have an element that is in a Sales-Force Lightening Application that is an HTML application. The element is a text field.
I need to get data into the test field. This is the id of the text field (as follows):
inputText115:3551;a
The issue I am having is this: "3551" might as well be "WXYZ" or "ABCD" because this value is a dynamic value that is generated by the application (and Sales-Force Lightening is full of this everywhere in their applications). It makes it difficult to test it with selenium because depending on the browser and the session ID, this value changes.
SO far I have not been able to do it. I have tried:
.click('[href="#/sObject/0012C000004TMmQQAW/view"]') <-- by href
.click('/html/body/div[5]/div[1]/section/div[1]/div[1]/div[2]/div/div/div[2]/div[1]/div/div[2]/div/div[4]/div/div/div[1]/table/tbody/tr[1]/th/span/a') <-- by xpath
So far, nothing has worked for me.
How can I interact/select an element in selenium using NodeJS with a dynamic ID??
If u have a Label before to the input field, u can find using label text. Usually the first input tag following a label is its text box
<div id="myDiv">
<label class="label" id="usernamelabel">Username</label>
<input type="text" id="inputText115:3551;a">
</div>
You can find it using
driver.findElement(By.xpath("//*[text() = 'Username']/following::input[1]"));