I am doing automation testing using visual studio.While selecting list from dropdown,only margin size changes.

enter image description here

I also tried using cssselector to wait but it's not works because cssselector is constant it not changes only the style attribute changes its size.How can wait for margin size to change. Only this part is keep on changing i have to wait until it changes its style.

enter image description here

  • Can you elaborate little bit more. what is your use case and what you want to achieve ?
    – NarendraR
    Jan 2 '18 at 12:30
  • @NarendraR only the style is keep on changing according to the dropdown type.I have to wait for the style attribute.Is it possible to wait only using style?
    – Mutu Arron
    Jan 2 '18 at 12:37

You can always create a custom Expected Condition to track the element location change.

Something along these lines:

WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));

IWebElement personAddress = d.FindElement(By.Id("window_personaddress_edit"));
string personAddressLocation = personAddress.Location;

wait.Until<IWebElement>((d) =>
    IWebElement element = d.FindElement(By.Id("window_personaddress_edit"));
    string newLocation = element.Location;
    if (newLocation.X != personAddressLocation.X || newLocation.Y != personAddressLocation.Y)
        return element;

    return null;

where d is your webdriver instance.


Just a WAG: To change margin style, element has to be redrawn. So you can wait until reference becomes stale, then wait some more until element appears again.

in Python: ExpectedConditions.staleness_of(element)

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.