You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Coded UI技术问题:点击动态生成表格单元格中的超链接

Let’s walk through how to automate this scenario smoothly—this approach works with popular test frameworks like Selenium, Cypress, or Playwright. Here’s the breakdown:

1. Locate the Row Matching the Specified Name

First, zero in on the row where the Name column matches your target value. Using a dynamic locator that ties the name to the row is key here. For example, in Selenium (Python):

# Replace "TargetName" with your actual name value
target_row = driver.find_element(By.XPATH, f"//tr[td[text()='TargetName']]")

This XPath selects the <tr> element containing a <td> with your target name text.

2. Wait for the Status to Change to "Complete"

Since the status updates dynamically from processing to Complete, you can’t just check it once—use an explicit wait to ensure the state changes. Selenium example:

from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

# Wait up to 30 seconds for the status cell in the target row to show "Complete"
status_cell = target_row.find_element(By.XPATH, "./td[2]")
WebDriverWait(driver, 30).until(
    EC.text_to_be_present_in_element((status_cell,), "Complete")
)

This waits until the second <td> (Status column) in your target row has the text "Complete". Adjust the timeout to match your app’s load speed.

Once the status is Complete, the third column’s link generates dynamically. Wait for this element to be clickable before interacting with it:

# Wait for the link in the third column to be clickable, then click it
link_element = WebDriverWait(driver, 10).until(
    EC.element_to_be_clickable((By.XPATH, "./td[3]/a", target_row))
)
link_element.click()

The XPath ./td[3]/a targets the <a> tag inside the third <td> of your target row—perfect since you noted the link is a child element of the cell.

Quick Tips for Other Frameworks

  • Cypress: Use cy.contains('TargetName').parent('tr').find('td:nth-child(2)').should('have.text', 'Complete') to wait for the status, then cy.contains('TargetName').parent('tr').find('td:nth-child(3) a').click() to hit the link.
  • Playwright: Use page.locator('tr:has(td:text("TargetName")) td:nth-child(2)').waitFor({state: 'visible', text: 'Complete'}) followed by page.locator('tr:has(td:text("TargetName")) td:nth-child(3) a').click().

Just tweak locators and framework-specific syntax to match your app’s exact HTML structure!

内容的提问来源于stack exchange,提问作者Nunna Swathi

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.27 04:07:50