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

Bulat
3003 silver badges9 bronze badges
asked Apr 2, 2017 at 13:44
1
  • Please shate the full code Commented Apr 3, 2017 at 2:45

2 Answers 2

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.

answered May 2, 2017 at 17:52
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.

answered Apr 2, 2017 at 14:34
1
  • hi you can see what i mean Commented Apr 2, 2017 at 15:34

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.