For some reason the I keep getting the wrong file returned to me. I keep getting a file with the name FC6...
I ran through the debugger and the search variable stays FC5 the whole time, I am guessing it has something to do with the contains() function, but I haven't had an issue anywhere else.
Looking for a way around this issue, thanks in advance.
public override void selectFiles()
{
foreach (string key in searchKeys)
{
IWebElement keyElement = base.getKeyElement("FC5");
//get the parent of the key element
IWebElement parentElement = keyElement.FindElement(By.XPath("./parent::*"));
//get the download tag in the parent element
IWebElement element = parentElement.FindElement(By.XPath("//*[contains(text(),'Download')]"));
Actions actions = new Actions(driver);
actions.MoveToElement(element).Click().Perform();
}
}
public IWebElement getKeyElement(string searchKeys)
{
IWebElement element = null;
string keyString = "//*[";
string[] keyList = searchKeys.Split(",");
bool firstKey = true;
foreach (string searchKey in keyList)
{
if (firstKey)
{
keyString = String.Join("", new string[] { keyString, "contains(text(), '", searchKey, "')" });
}
else
{
keyString = String.Join("", new string[] { keyString, " and contains(text(), '", searchKey, "')" });
}
firstKey = false;
}
keyString = String.Join("", new string[] { keyString, "]" });
element = waitForVisibility(By.XPath(keyString));
return element;
}
public IWebElement waitForVisibility(By element)
{
try
{
return new WebDriverWait(driver, TimeSpan.FromSeconds(5)).Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementIsVisible(element));
}
catch
{
return null;
}
}