I am trying to Upload files by clicking on "Upload completed form". When I use XPath to locate it and click on it, nothing works. Is there a way out?
Below is the HTML from inspecting Chrome.
<button ng-if="$root.AccessLevel.Standard" class="btn btn--small btn--icon ng-pristine ng-valid ng-touched" ng-model="vm.uploads[workCategory.Id].reference" ngf-max-size="'5MB'" ngf-model-invalid="vm.uploads[workCategory.Id].referenceInvalid" ngf-pattern="'.pdf,.doc,.docx,.bmp,.gif,.jpg,.jpeg,.tif,.wmf,.png'" ngf-select="vm.uploadFile($file, 'WorkCategoryReference', workCategory.Id, workCategory.References, workCategory.Id+'uploadRef')">
<span promise="vm.promises[workCategory.Id+'uploadRef']">
<span ng-hide="pending" class="">
<i class="fa fa-lg fa-cloud-upload"></i>
</span>
<span ng-show="pending" class="ng-hide">
<i class="fa fa-lg fa-refresh fa-spin"></i>
</span>
</span>
Upload completed form
</button>
Below is my NUnit class with the XPath passed in
wait.PathWaitAndClick(driver, "*[@id=\"accordiongroup - 299 - 4516 - panel\"]/div/div[2]/div[1]/table/tfoot/tr/td/button", 2000);
Also below I’m using WebExtension method.
public static void PathWaitAndClick(this WebDriverWait wait, IWebDriver driver, string path, int pause = 0)
{
if (pause > 0)
{
System.Threading.Thread.Sleep(pause);
}
wait.Until(ExpectedConditions.ElementToBeClickable(By.XPath(path)));
IWebElement viewAllWc = driver.FindElement(By.XPath(path));
if (pause > 0)
{
System.Threading.Thread.Sleep(pause);
}
viewAllWc.Click();
}