简体   繁体   中英

Get element size using Selenium with C#

I am trying to check if flash video is minimized or maximized. Tried to do something like this:

var video = Program.Driver.FindElement(By.XPath("//object[contains(@id, 'player_api')]"));

int videoSize = video.Size.Width;

if (videoSize > 1024)
{
     //Do something...
}

But I am getting fixed size of HTML element. Any suggestion?

As far as I can see you can locate the following element:

var video = Program.Driver.FindElement(By.XPath("//*[@id='player_api']/param[6]"));

Then get its value and then find the video sizes in the flash object. You can even deserialize the value to C# object from the JSON. Check the image: http://screencast.com/t/sYu3DYxo6V

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM