尝试使用WebDriverWait
如下: -
var wait = new WebDriverWait(Driver.Instance, TimeSpan.FromSeconds(20));
var el = wait.Until(ExpectedConditions.ElementIsVisible(By.CssSelector("td.grid3-td-TRAVNAME div.x-grid3-col-TRAVNAME")));
el.Click();
已编辑:如果不幸的是由于无法单击unselectable="on"
,请在单击之前删除此属性属性IJavascriptExecutor
,如下所示:-
var wait = new WebDriverWait(Driver.Instance, TimeSpan.FromSeconds(20));
var el = wait.Until(ExpectedConditions.ElementIsVisible(By.CssSelector("td.grid3-td-TRAVNAME div.x-grid3-col-TRAVNAME")));
IJavaScriptExecutor js = Driver.Instance as IJavaScriptExecutor;
el = (IWebElement)js.ExecuteScript("arguments[0].removeAttribute('unselectable'); return arguments[0];", el);
el.Click();
编辑:- cssSelector 在这里不起作用尝试使用By.Xpath()
如下:-
var el = wait.Until(ExpectedConditions.ElementIsVisible(By.Xpath(".//div[contains(text(), 'ARUNACHALAM/SHAN')]")));