我想知道如何找到要上传的按钮的元素,然后通过下面的HTML代码用鼠标单击继续进行操作:
===below===
no "libgrpc++.so" but there are only:
libgrpc++.so.1
libgrpc++.so.1.8.5
答案 0 :(得分:2)
根据您的评论:
是的,我要单击按钮,因为我上传图像后即上传 按钮仅出现。我该怎么办?
您必须使用WebDriverWait
等到元素可点击:
// after you have uploaded an image
var wait = new WebDriverWait(driver, TimeSpan.FromMinutes(1));
var clickableElement = wait.Until(ExpectedConditions.ElementIsClickable(By.Id("uploadImageButtonSEC-2")));
clickableElement.click();
这将至少等待1分钟,直到元素可以单击,然后才能单击它。
注意:如果您的ID是通用ID,则可以使用xPath
进行查找:
//button[starts-with(@id, 'uploadImageButton')]
和代码:
// after you have uploaded an image
var wait = new WebDriverWait(driver, TimeSpan.FromMinutes(1));
var clickableElement = wait.Until(ExpectedConditions.ElementIsClickable(By.Xpath("//button[starts-with(@id, 'uploadImageButton')]")));
clickableElement.click();