0

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 code – ChathuD Apr 3 '17 at 2:45
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.

0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.