如果元素在页面的用户控件中,如何访问元素并输入键?

问题描述 投票:1回答:1

我在页面中有一个用户控件UserInfo。用户控件中有一个名称为cbType的组合框。如果我使用硒,如何访问此组合框进行测试?

下面是我的代码:

[TestMethod]
public void Test_GoToAddDepositPage()
{
     IWebElement el = driver.FindElement(By.Id("ctl00_MainContent_ucDepositMasterInput_rcbAccountNo_Input"));
           el.InsertKeys("Big"")  
}
c# visual-studio selenium user-controls selenium-chromedriver
1个回答
0
投票

我的猜测是您要使用硒暴露的SendKeys功能

https://selenium.dev/selenium/docs/api/dotnet/html/M_OpenQA_Selenium_Interactions_Actions_SendKeys.htm

有两种口味

这可能是您需要的:

public Actions SendKeys(
    IWebElement element,
    string keysToSend
)

这将直接发送到浏览器:

public Actions SendKeys(
    string keysToSend
)
© www.soinside.com 2019 - 2024. All rights reserved.