3

I am trying to access the order attribute for the html tag header > div.column Here's my code : var element = driver.FindElement(By.CssSelector("header > div.column")).GetCssValue("order");

But I got Object reference issue for GetCssValue . looks like the selected tag doesnt have the attribute "order".

What I am missing here? Attached screenshot with html codeenter image description here

UPDATE I am using BrowserStack for the testing and when I use Chrome as the browser , it works , but the same code does not work on when I chose IE or Iphone. Is it because I need to add the IE driver or something like that?

IndieTech Solutions
  • 2,527
  • 1
  • 21
  • 36

1 Answers1

1

order CSS property can be not supported depending on the browser.

You may try approaching it differntly - from the javascript using the getComputedStyle() method:

IWebElement element = driver.FindElement(By.CssSelector("header > div.column"))
IJavaScriptExecutor js = driver as IJavaScriptExecutor;
string title = (string)js.ExecuteScript("return window.getComputedStyle(arguments[0]).getPropertyValue('order');", element);
alecxe
  • 462,703
  • 120
  • 1,088
  • 1,195