This is my code in C# I press the delete button and open a pop up where I select the amount of deletions that I want to delete and press again on delete it will delete.
Perhaps it is more correct to ask how I do while this delete element:
PropertiesCollections.driver.FindElement (By.LinkText ("Delete")). Click ();
As long as it appear true that it will perform the deletion steps and if it does not continue the test:
PropertiesCollections.driver.FindElement(By.LinkText("Delete")).Click();
new SelectElement(PropertiesCollections.driver.FindElement(By.Id("remove_shares"))).SelectByText("1");
PropertiesCollections.driver.FindElement(By.XPath("(//button[@type='button'])[2]")).Click();
I want to make a loop if the delete button appear, it will do all the steps of the deletion, and if it does not continue for the other test.
I've tried with this code:
var links = PropertiesCollections.driver.FindElement(By.LinkText("Delete")).Click();
while (links = true)
{
PropertiesCollections.driver.FindElement(By.LinkText("Delete")).Click();
PropertiesCollections.driver.FindElement(By.Id("remove_shares"));
PropertiesCollections.driver.FindElement(By.XPath("(//button[@type='button'])[2]")).Click();
}
But I get an error:
Error 1 Cannot assign void to an implicitly-typed local variable
-
Please shate the full codeChathuD– ChathuD2017年04月03日 02:45:45 +00:00Commented Apr 3, 2017 at 2:45
2 Answers 2
The problem is this line of code:
var links = PropertiesCollections.driver.FindElement(By.LinkText("Delete")).Click();
The Click method does not return an element, so you can't assign it.
Sometimes it helps to insert long waits in between actions. This can help you actually see what is going on in the browser, rather than having pages flash before your eyes.
One thing to check is that the browser window is big enough. I've had problems with this specific error because the browser launched smaller than necessary for the element to be clickable (mine was hidden in a drop down!). Try launching in a maximised window if this might be the issue.
-
hi you can see what i meanDaniel Shmayovich– Daniel Shmayovich2017年04月02日 15:34:13 +00:00Commented Apr 2, 2017 at 15:34