인가가 부모 요소, 형제 요소 또는 자식 요소 만python webdriver로 부모 요소를 찾는 방법은 무엇입니까?
driver.find_element_parent?
또는
driver.find_element_next?
또는
driver.find_element_previous
등을 찾을 파이썬 + 셀레늄에 대한 모든 방법?
예 :
<tr>
<td>
<select>
<option value=0, selected='selected'> </option>
<option value=1, > </option>
<option value=2,> </option>
</select>
</td>
<td> 'abcd'
<input name='A'> </input>
<td>
<tr>
나는 다음과 같은 시도했지만, 실패 :
input_el=driver.find_element_by_name('A')
td_p_input=find_element_by_xpath('ancestor::input')
어떻게 내가 입력 요소의 부모를 얻을 수 있습니다 다음, 마지막으로, 이 옵션을 얻을을 선택하셨습니까? 귀하의 예 I에서
selected_option = driver.find_element_by_xpath('//option[@selected="selected"]')
'../'구문이 작동하지 않으면 './ ..'및'./../ .. '이 예상대로 작동합니다. 뒤에 슬래시를 추가하지 마십시오. –