I have a first row in a table that has empty TDs filled with input TEXTBOXs or TEXTAREAs here is what the row looks like
<tr>
<td class="gwf_variable_table_control_column">
<div class="gwf_tooltip"><input type="button" class="gwf-round-button" value="^" onclick="InsertRowBefore('MeteorologicalVariables', this, 'TextBox')" title="Add row before"></div>
<div class="gwf_tooltip"><input type="button" class="gwf-round-button" value="X" onclick="DeleteRow('MeteorologicalVariables', this)" title="Delete current row"></div>
<div class="gwf_tooltip"><input type="button" class="gwf-round-button" value="v" onclick="InsertRowAfter('MeteorologicalVariables', this, 'TextBox')" title="Add row after"></div>
</td>
<td><input type="text" class="fmc-tb-appearance fmc-tb-font fmc-tb-height" style="width:100%"></td>
<td><textarea class="fmc-tb-appearance fmc-tb-font" style="height:60px;min-width:200px;width:200px;max-width:200px;"></textarea></td>
<td><textarea class="fmc-tb-appearance fmc-tb-font" style="height:60px;min-width:200px;width:200px;max-width:200px;"></textarea></td>
<td><input type="text" class="fmc-tb-appearance fmc-tb-font fmc-tb-height" style="width:100%"></td>
<td><input type="text" class="fmc-tb-appearance fmc-tb-font fmc-tb-height" style="width:100%"></td>
<td><input type="text" class="fmc-tb-appearance fmc-tb-font fmc-tb-height" style="width:100%"></td>
<td><textarea class="fmc-tb-appearance fmc-tb-font" style="height:60px;min-width:275px;width:275px;max-width:275px;"></textarea></td>
</tr>
and here is the table itself I need to index to this table then hop into each text box or text area and fill them in:
<table id="MeteorologicalVariables" class="gwf_variable_table">
<colgroup>
<col>
<col style="min-width:150px">
<col style="min-width:200px">
<col style="min-width:200px">
<col style="min-width:200px">
<col style="min-width:220px">
<col style="min-width:220px">
<col style="min-width:275px">
</colgroup>
<tbody>
<tr style="display: table-row;">
<td class="gwf_variable_table_control_column"></td>
<td style="max-width:150px" class="fmc-table-label-font fmc-tb-height">Variable</td>
<td style="max-width:200px" class="fmc-table-label-font fmc-tb-height">Station Name</td>
<td style="max-width:200px" class="fmc-table-label-font fmc-tb-height">Sensor(s)</td>
<td style="max-width:200px" class="fmc-table-label-font fmc-tb-height">Height / Depth (m)</td>
<td style="max-width:220px" class="fmc-table-label-font fmc-tb-height">Record Period</td>
<td style="max-width:220px" class="fmc-table-label-font fmc-tb-height">Measurement Frequency</td>
<td style="max-width:275px" class="fmc-table-label-font fmc-tb-height">Notes / Details</td>
</tr>
<tr>
<td class="gwf_variable_table_control_column">
<div class="gwf_tooltip"><input type="button" class="gwf-round-button" value="^" onclick="InsertRowBefore('MeteorologicalVariables', this, 'TextBox')" title="Add row before"></div>
<div class="gwf_tooltip"><input type="button" class="gwf-round-button" value="X" onclick="DeleteRow('MeteorologicalVariables', this)" title="Delete current row"></div>
<div class="gwf_tooltip"><input type="button" class="gwf-round-button" value="v" onclick="InsertRowAfter('MeteorologicalVariables', this, 'TextBox')" title="Add row after"></div>
</td>
<td><input type="text" class="fmc-tb-appearance fmc-tb-font fmc-tb-height" style="width:100%"></td>
<td><textarea class="fmc-tb-appearance fmc-tb-font" style="height:60px;min-width:200px;width:200px;max-width:200px;"></textarea></td>
<td><textarea class="fmc-tb-appearance fmc-tb-font" style="height:60px;min-width:200px;width:200px;max-width:200px;"></textarea></td>
<td><input type="text" class="fmc-tb-appearance fmc-tb-font fmc-tb-height" style="width:100%"></td>
<td><input type="text" class="fmc-tb-appearance fmc-tb-font fmc-tb-height" style="width:100%"></td>
<td><input type="text" class="fmc-tb-appearance fmc-tb-font fmc-tb-height" style="width:100%"></td>
<td><textarea class="fmc-tb-appearance fmc-tb-font" style="height:60px;min-width:275px;width:275px;max-width:275px;"></textarea></td>
</tr>
here is what I have tried so far:
text1 = driver.find_element("xpath", '(//table[@id = "MeteorologicalVariables"]//input[@value = "^"])[1]/preceding-sibling::td[1]')
text1.send_keys("text1")
here is the error I get:
Traceback (most recent call last):
File "d:codeEnterDataObsobservations.py", line 77, in <module>
text1 = driver.find_element("xpath", '(//table[@id = "MeteorologicalVariables"]//input[@value = "^"])[1]/preceding-sibling::td[1]')
File "C:UsersRobMeAppDataLocalPackagesPythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0LocalCachelocal-packagesPython310site-packagesseleniumwebdriverremotewebdriver.py", line 741, in find_element
return self.execute(Command.FIND_ELEMENT, {"using": by, "value": value})["value"]
File "C:UsersRobMeAppDataLocalPackagesPythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0LocalCachelocal-packagesPython310site-packagesseleniumwebdriverremotewebdriver.py", line 347, in execute
self.error_handler.check_response(response)
File "C:UsersRobMeAppDataLocalPackagesPythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0LocalCachelocal-packagesPython310site-packagesseleniumwebdriverremoteerrorhandler.py", line 229, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"(//table[@id = "MeteorologicalVariables"]//input[@value = "^"])[1]/preceding-sibling::td[1]"}
1