Merge pull request #3 from MicrosoftEdge/av

Av
This commit is contained in:
David Brett 2016-04-18 16:42:00 -07:00
Родитель 2c55a7023d 4b512418ab
Коммит 71fe27c029
2 изменённых файлов: 34 добавлений и 37 удалений

Просмотреть файл

@ -321,5 +321,34 @@ namespace Microsoft.Edge.A11y
return toreturn; return toreturn;
} }
public static double ParseMystery(this object o)
{
try
{
return (int)o;
}
catch { }
try
{
return (Int64)o;
}
catch { }
try
{
return (double)o;
}
catch { }
try
{
return double.Parse((string)o);
}
catch { }
throw new InvalidCastException("Cannot parse to int, double, or string");
}
} }
} }

Просмотреть файл

@ -296,25 +296,9 @@ namespace Microsoft.Edge.A11y
{ {
string videoId = "video1"; string videoId = "video1";
Func<bool> VideoPlaying = () => (bool)driver.ExecuteScript("return !document.getElementById('" + videoId + "').paused", 0); Func<bool> VideoPlaying = () => (bool)driver.ExecuteScript("return !document.getElementById('" + videoId + "').paused", 0);
Func<double> VideoVolume = () => Func<double> VideoVolume = () => driver.ExecuteScript("return document.getElementById('" + videoId + "').volume", 0).ParseMystery();
{
var volume = driver.ExecuteScript("return document.getElementById('" + videoId + "').volume", 0);
try
{
return (int)volume;
}
catch { }
try
{
return (double)volume;
}
catch { }
throw new ArgumentException("Unable to cast to int or double");
};
Func<bool> VideoMuted = () => (bool)driver.ExecuteScript("return document.getElementById('" + videoId + "').muted", 0); Func<bool> VideoMuted = () => (bool)driver.ExecuteScript("return document.getElementById('" + videoId + "').muted", 0);
Func<double> VideoElapsed = () => (double)driver.ExecuteScript("return document.getElementById('" + videoId + "').currentTime", 0); Func<double> VideoElapsed = () => driver.ExecuteScript("return document.getElementById('" + videoId + "').currentTime", 0).ParseMystery();
//Case 1: tab to video element and play/pause //Case 1: tab to video element and play/pause
driver.SendSpecialKeys(videoId, "Space"); driver.SendSpecialKeys(videoId, "Space");
@ -427,25 +411,9 @@ namespace Microsoft.Edge.A11y
{ {
string audioId = "audio1"; string audioId = "audio1";
Func<bool> AudioPlaying = () => (bool)driver.ExecuteScript("return !document.getElementById('" + audioId + "').paused", 0); Func<bool> AudioPlaying = () => (bool)driver.ExecuteScript("return !document.getElementById('" + audioId + "').paused", 0);
Func<double> AudioVolume = () => Func<double> AudioVolume = () => driver.ExecuteScript("return document.getElementById('" + audioId + "').volume", 0).ParseMystery();
{
var volume = driver.ExecuteScript("return document.getElementById('" + audioId + "').volume", 0);
try
{
return (int)volume;
}
catch { }
try
{
return (double)volume;
}
catch { }
throw new ArgumentException("Unable to cast to int or double");
};
Func<bool> AudioMuted = () => (bool)driver.ExecuteScript("return document.getElementById('" + audioId + "').muted", 0); Func<bool> AudioMuted = () => (bool)driver.ExecuteScript("return document.getElementById('" + audioId + "').muted", 0);
Func<double> AudioElapsed = () => (double)driver.ExecuteScript("return document.getElementById('" + audioId + "').currentTime", 0); Func<double> AudioElapsed = () => driver.ExecuteScript("return document.getElementById('" + audioId + "').currentTime", 0).ParseMystery();
//Case 1: Play/Pause //Case 1: Play/Pause
driver.SendTabs(audioId, 1); //Tab to play button driver.SendTabs(audioId, 1); //Tab to play button