내 프로젝트를 진행할 수 있도록 selenium webdriver가이 링크를 클릭하고 싶습니다. 여기 내 코드가있다. 오류는 없지만 링크를 클릭하지는 않습니다.Selenium이 (가) 아니요, 이름, ID 또는 클래스를 클릭하지 않습니다.
x = driver.find_element_by_xpath('/html/body/table[2]/tbody/tr[2]/td/span/
a[7]')
x.click()
다음은 HTML 나는 7 링크를 클릭합니다
<tr>
<td width="100%">
<span style="white-space: nowrap">
<a href="#">
<img src="https://staffmate.com/imagessm/OEA_sm_lt.gif" border="0" width="125" height="36">
</a>
<a href="#">
<img src="https://staffmate.com/imagessm/OPOS_sm_lt.gif" border="0" width="125" height="36">
</a>
<a href="#">
<img src="https://staffmate.com/imagessm/OCTR_sm_lt.gif" border="0" width="125" height="36">
</a>
<a href="#">
<img src="https://staffmate.com/imagessm/OCL_sm_lt.gif" border="0" width="125" height="36">
</a>
<a href="#">
<img src="https://staffmate.com/imagessm/OVEN_sm_lt.gif" border="0" width="125" height="36">
</a>
<a href="#">
<img src="https://staffmate.com/imagessm/OEV_sm_dk.gif" border="0" width="125" height="36">
</a>
<a href="eprintreports.php?eSessID=199495633810875522501415473608154261624185901388039708769020171218111124">
<img src="https://staffmate.com/imagessm/PREP_sm_lt.gif" border="0" width="125" height="36">
</a>
</span>
</td>
</tr>
입니다. 크롬 검사 도구에서 바로 xpath를 복사했습니다. 절대 xpath는 신뢰할 수 없다는 것을 알고 있지만 클래스 이름, ID 또는 이름이 없을 때 사용할 수있는 것은 무엇입니까? 도움을 많이 주시면 감사하겠습니다.
당신이 URL을 공유 할 수 다음과 같이 당신은
<img>
태그까지 더 깊게하고click()
를 호출해야합니까? –URL을 추가했습니다. – Cameron
URL이 설명에없는 것 같습니다. 추가해주세요. – Danny