Unable to read input button

The application we are using changes id’s dynamically. I’m trying to do an it on the contents of an readonly input button but can’t seem to get the text.

WebDriver driver = DriverFactory.getWebDriver()

WebElement tableOpenSessions = driver.findElement(By.xpath('//div[@id=\'s-site-body\']/article/div/div[2]/div/div/div/section/div/div/div[2]/div/div/section/div/div/div/div/article/div[2]/div/div/div/div[2]/table'))
WebElement tableOpenSessionsDetails = driver.findElement(By.xpath('//div[@id=\'s-site-body\']/article/div/div[2]/div/div/div/section/div/div/div[2]/div/div/section/div/div/div/div/article/div[2]/div/div/div[2]/div[2]/table'))
WebElement tableActiveProcesses = driver.findElement(By.xpath('//div[@id=\'s-site-body\']/article/div/div[2]/div/div/div/section/div/div/div[3]/div/div/div/div/section/div/div/div/div/article/div[2]/div/div/div/div[2]/table'))

List<WebElement> rowsOpenSessions = tableOpenSessions.findElements(By.tagName('tr'))
List<WebElement> rowsOpenSessionsDetails = tableOpenSessionsDetails.findElements(By.tagName('tr'))

for (int i = 0; i < rowsOpenSessions.size(); i++) {
	List<WebElement> colsOpenSessions = rowsOpenSessions.get(i).findElements(By.tagName('td'))
	List<WebElement> colsOpenSessionsDetails = rowsOpenSessionsDetails.get(i).findElements(By.tagName('td'))
	
	if (colsOpenSessions.size() > 0) {
		colsOpenSessions.get(0).click()
	
		if (colsOpenSessionsDetails.size() > 3) {
			WebElement folderNameInput = colsOpenSessionsDetails.get(2).findElement(By.tagName("input"))
			String a = folderNameInput.getText()
			WebUI.comment(a)

			WebElement folderNameInput2 = colsOpenSessionsDetails.get(2).findElement(By.xpath("//input"))
			String b = folderNameInput2.getText()
			WebUI.comment(b)
		}
	}

	WebUI.delay(2)
}

Both a and b are empty.

image

<td class="s-grid-cell-edit s-inplace"><div class="s-grid-cell-value-edit s-inplace-value-edit s-readonly"><input type="text" autocomplete="off" spellcheck="false" autocorrect="off" class="s-inplace-input s-readonly" maxlength="10" id="9-154-input" readonly="readonly" title=""></div></td>

Any help would be appreciated.

@rschenkel Have you tried to get the input element from the div element. Unfortunately, I don’t know how common the two class attributes are. If you can Inspect the HTML for the element and then test the below xpath to see if it is unique (should say 1 of 1 to the right). If not then you can loop through the web elements until you land on the correct one.

//div[@class=‘s-grid-cell-value-edit s-inplace-value-edit s-readonly’]/input[@class=‘s-inplace-input s-readonly’]

I had another idea. You are using getText, but how about using getAttribute(“value”)?