0

i try to write a code which click on several links in a table.

Here is the HTML Code:

<div id="gadget-34365" class="gadget-inline" style="height: 905px;">
<div class="results-wrap search-results-dashboard-item">
    <div class="search-results-dashboard-item-issue-table ">
        <issuetable-web-component>
            <table class="issue-table">
                <thead></thead>
                <tbody>
                    <tr rel="548420" data-issuekey="SOLI-30715" class="issuerow"></tr>
                    <tr rel="532948" data-issuekey="SOLI-29811" class="issuerow"></tr>
                    <tr rel="548424" data-issuekey="SOLI-30719" class="issuerow">
                        <td class="priority"></td>
                        <td class="issuetype"></td>
                        <td class="issuekey">
                            <a class="issue-link" data-issue-key="SOLI-30719" href="https://jira.t-systems-mms.eu/browse/SOLI-30719">SOLI-30719</a>
                        </td>
                        <td class="summary"></td>
                        <td class="status"></td>
                        <td class="customfield_10090">          
                            <span title="26.12.17">
                                <time datetime="2017-12-26">26.12.17</time>
                            </span>
                        </td>
                        <td class="issue_actions"> </td>
                    </tr>
                    <tr rel="553117" data-issuekey="SOLI-31203" class="issuerow"></tr>
                    <tr rel="550261" data-issuekey="SOLI-30912" class="issuerow"></tr>
                </tbody>
            </table>
        </issuetable-web-component>
    </div>
</div>

My Code should check the table in the column "customfield_10090" if the project has to be done in the next two weeks. After that it should click on the link in column "issuekey".

This is my Code so far:

td_list = WebDriverWait(driver, 10).until(lambda driver: driver.find_elements_by_css_selector("#gadget-34365 > div > div"))
for td in td_list:
    time = driver.find_elements_by_tag_name("time")    
    for row in driver.find_elements_by_css_selector("#gadget-34365 > div > div > issuetable-web-component > table > tbody > tr:nth-child(7) > td.customfield_10090"):
        if time == now or now <= date_in_two_weeks:
            for cell in driver.find_elements_by_class_name("issuekey"):
                Link = driver.find_element_by_link_text("SOLI")
                Link.click()
                driver.get_screenshot_as_file("Test.png")
        else:
            print "No Projects found in the next two weeks !"

I tried every single solution i could find here, but nothing could solve my problem.

What i´m missing or is wrong? Hope some one can help :)

EDIT:

This is the error i get:

Traceback (most recent call last):
File "comment.py", line 42, in <module>
Link = driver.find_element_by_link_text("SOLI")
File "/usr/local/lib/python2.7/dist packages/selenium/webdriver/remote/webdriver.py", line 389, in find_element_by_link_text
return self.find_element(by=By.LINK_TEXT, value=link_text)
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 843, in find_element
'value': value})['value']
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 308, in execute
self.error_handler.check_response(response)
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/errorhandler.py", line 194, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException: Message: no such element: 
Unable to locate element: {"method":"link text","selector":"SOLI"}
(Session info: chrome=62.0.3202.75)
(Driver info: chromedriver=2.26.436382 
(70eb799287ce4c2208441fc057053a5b07ceabac),platform=Linux 4.9.17-c9 x86_64)
diem_L
  • 389
  • 5
  • 22

2 Answers2

0

Your css selector seems to be wrong. You're trying to select tr:nth-child(7), however, I believe that it should be tr:nth-child(3)

  • The 'SOLI' selector is wrong. Consider selecting the a element directly if it's the only one. –  Nov 23 '17 at 08:32
  • Changed it to driver.find_element_by_tag_name("a").click() .. but the click doesn´t happen. In the screenshot it is still on the same page – diem_L Nov 23 '17 at 08:35
0

The link text of element that you are trying to find does not match "SOLI", but rather "SOLI-30719". Change your selector from

driver.find_element_by_link_text("SOLI")

to

driver.find_element_by_partial_link_text("SOLI")

Hope that helps.

Mario Nikolaus
  • 2,346
  • 1
  • 21
  • 28
  • Unfortunatly not :( This is the error i get: **selenium.common.exceptions.WebDriverException: Message: unknown error: Element is not clickable at point (383, -5335)** – diem_L Nov 23 '17 at 10:41
  • But at least now you are targeting correct element. For the new error refer to https://stackoverflow.com/questions/11908249/debugging-element-is-not-clickable-at-point-error – Mario Nikolaus Nov 23 '17 at 11:04
  • This should be the `Accepted Answer`. For `Element is not clickable at point (383, -5335)` see this [Element is not clickable at point (36, 72). Other element would receive the click:](https://stackoverflow.com/questions/44912203/selenium-web-driver-java-element-is-not-clickable-at-point-36-72-other-el/44916498#44916498) – undetected Selenium Nov 23 '17 at 12:44