In my spec-flow project, I have created static Screenshot class. I have also created static methods to take screen shots. But at run time, my driver is consistently null. How can I solve this problem.
Below is the code snippet:
public static class Screenshot
{
public static void TakeScreenshots(this IWebDriver driver, string path = #"result")
{
var takescreenshot = (driver as ITakesScreenshot) != null;
if (!takescreenshot)
return;
var filename = string.Empty + DateTime.Now.Hour + DateTime.Now.Minute + DateTime.Now.Second + DateTime.Now.Millisecond;
filename = path + #"\" + filename + ".png";
var ss = ((ITakesScreenshot)driver).GetScreenshot();
var screenshot = ss.AsBase64EncodedString;
byte[] screenshotAsByteArray = ss.AsByteArray;
ss.SaveAsFile(filename, ScreenshotImageFormat.Png);
}
}
I call in my afterstep hook like so:
[AfterStep()]
public static void AfterStep()
{
if (ScenarioContext.Current.TestError == null)
{
stepStatus = Status.Pass;
}
else
{
ScreenShot.TakeScreenshots(driver);
}
test.Log(stepStatus, stepLogText);
}
Related
public void FileDownloadFromAzure(String fileWithPath)
{
char separator = '\\';
String localRootDir = "C:\\XYZ";
String azureRootDir = "XYZ";
String fileName = fileWithPath.Substring(fileWithPath.LastIndexOf(separator) + 1);
String dirName = fileWithPath.Substring(0, fileWithPath.LastIndexOf(separator));
String destDirWithFullPath = localRootDir + "\\" + dirName + "\\" + fileName;
String sourceDirWithFullPath = azureRootDir + "\\" + dirName;
try
{
ShareDirectoryClient directory = m_ShareClient.GetDirectoryClient(sourceDirWithFullPath);
ShareFileClient file = directory.GetFileClient(fileName);
// Download the file
ShareFileDownloadInfo download = file.Download();//call returns null
using (Stream stream = m_FileSystem.File.OpenWrite(destDirWithFullPath))
{
download.Content.CopyTo(stream);
}
}
catch(Exception ex) {}
}
FileDownloadFromAzure above works as expected.
I am trying to write unit test for the same.
[TestMethod]
public void FileDownloadFromAzure_ValidCall()
{
//arrange
var shareDirectoryClient = new Mock<ShareDirectoryClient>();
var shareFileClient = new Mock<ShareFileClient>();
var shareFileDownloadInfo = new Mock<Response<ShareFileDownloadInfo>>();
shareFileClient.Setup(s => s.Download(It.IsAny<HttpRange>(),
false, null,
It.IsAny<CancellationToken>()))
.Returns(shareFileDownloadInfo.Object);
shareDirectoryClient.Setup(s => s.GetFileClient(It.IsAny<String>())).Returns(shareFileClient.Object);
_shareClient.Setup(s => s.GetDirectoryClient(It.IsAny<String>())).Returns(shareDirectoryClient.Object);
var sut = new FileSystemIOProcessor(_shareClient.Object,
_fileSystem.Object);
//act
String fileWithPath = "TEST\\TEST.TXT";
var actual = sut.FileDownloadFromAzure(fileWithPath);
//assert
Assert.AreEqual(true, actual);
}
But I am new to using mock. Could you please share your thoughts on mocking ShareFileClient.Download() method?
Blockquote
I have resolved the issue by taking a clue from the following post.
Mocking File.OpenWrite()
String const TEMP_DIR_NAME = "TEMPDIR";
String const TEMP_FILE_NAME = "TEMPFILE.TXT";
[TestInitialize]
public void TestInitialize()
{
//...Create temp dir and temp file as part of TestInitialize()
}
[TestMethod]
public void FileCopyFromAzureToLocal()
{
...
//Arrange
String sourceDirWithFullPath = azureRootDir + "\\" + TEMP_DIR_NAME;
ShareDirectoryClient directory = shareClient.GetDirectoryClient(sourceDirWithFullPath);
ShareFileClient file = directory.GetFileClient(TEMP_FILE_NAME);
shareFileDownloadInfo = file.Download();
shareFileClient.Setup(s => s.Download(It.IsAny<HttpRange>(),
false, null,
It.IsAny<CancellationToken>()))
.Returns(shareFileDownloadInfo);
...
//Act
//Assert
}
[ClassCleanup]
public static void Class_Cleanup()
{
//...
DeleteDirectoryOnAzure(TEMP_DIR_NAME, recursive=true);
//...
}
Can anyone help me to resolve my healthKit capability issue for a unity app.
I am trying to add healthKit capability to my unity app. I am using BEHEALTHKIT and HealthKitBuildProcessor.cs editor class to add capability and other dependencies. Following are the code I am using .But for some reason healthkit Capability and entitlements are not adding through this code (permission parameters are adding to plist), and returning null when I print Debug.Log("newEntitlements: " + newEntitlements);Also my build failing with an error saying "provisioning profile doesn't support the HealthKit Capability"
I have already added HealthKit capability for the profile from developer.apple.com.
Unity version: 2019.4.4f1
public class HealthKitBuildProcessor : IProcessSceneWithReport
{
private static string shareString = null;
private static string updateString = null;
private static string clinicalString = null;
/*! #brief required by the IProcessScene interface. Set high to let other postprocess scripts run first. */
public int callbackOrder {
get { return 100; }
}
/*! #brief Searches for HealthKitDataTypes objects & reads the usage strings for the OnPostprocessBuild phase.
#param scene the scene being processed.
#param report a report containing information about the current build
*/
public void OnProcessScene(Scene scene, BuildReport report) {
GameObject[] rootObjects = scene.GetRootGameObjects();
foreach (GameObject obj in rootObjects) {
HealthKitDataTypes types = obj.GetComponentInChildren<HealthKitDataTypes>();
if (types != null) {
if (types.AskForSharePermission()) {
HealthKitBuildProcessor.shareString = types.healthShareUsageDescription;
}
if (types.AskForUpdatePermission()) {
HealthKitBuildProcessor.updateString = types.healthUpdateUsageDescription;
}
/*if (types.AskForClinicalPermission()) {
HealthKitBuildProcessor.clinicalString = types.clinicalUsageDescription;
}*/
}
}
}
/*! #brief Updates the Xcode project.
#param buildTarget the target build platform
#param path the path of the target build
*/
[PostProcessBuildAttribute(10)]
public static void OnPostprocessBuild(BuildTarget buildTarget, string path) {
Debug.Log("--- BEHEALTHKIT POST-PROCESS BUILD ---");
if (buildTarget == BuildTarget.iOS) {
//string projPath = path + "/Unity-iPhone.xcodeproj/project.pbxproj";
//Debug.Log("BE:PROJECT PATH :" + projPath);
var projPath = PBXProject.GetPBXProjectPath(path);
var proj = new PBXProject();
proj.ReadFromString(System.IO.File.ReadAllText(projPath));
#if UNITY_2019_3_OR_NEWER
string mainTarget = proj.GetUnityMainTargetGuid();
string frameworkTarget = proj.GetUnityFrameworkTargetGuid();
Debug.Log("--- BE: UNITY_2019_3_OR_NEWER ---");
Debug.LogFormat("main target: {0}", mainTarget);
Debug.LogFormat("framework target: {0}", frameworkTarget);
#else
string targetName = PBXProject.GetUnityTargetName();
string mainTarget = proj.TargetGuidByName(targetName);
Debug.Log("---BE: ELSE UNITY_2019_3_OR_NEWER ---");
Debug.Log("main target: {0}", mainTarget);
Debug.Log("targetName: ", targetName);
#endif
bool addHealthRecordsCapability = (clinicalString != null);
//Debug.Log("addHealthRecordsCapability: ", addHealthRecordsCapability);
// Info.plist
//-----------
Debug.Log("---BE: PLIST ---");
var info = ProcessInfoPList(path, addHealthRecordsCapability);
// Entitlements
//--------------
Debug.Log("---BE: ProcessEntitlements ---");
string entitlementsRelative = ProcessEntitlements(path, proj, mainTarget, info, addHealthRecordsCapability);
#if UNITY_2019_3_OR_NEWER
// add HealthKit capability
Debug.Log("------projPath "+projPath);
ProjectCapabilityManager capabilities = new ProjectCapabilityManager(projPath, "Entitlements.entitlements", null, mainTarget);
capabilities.AddHealthKit();
Debug.Log("---BE:Capability UNITY_2019_3_OR_NEWER ---");
// add HealthKit Framework
//proj.AddFrameworkToProject(frameworkTarget, "HealthKit.framework", true);
// Set a custom link flag
//proj.AddBuildProperty(frameworkTarget, "OTHER_LDFLAGS", "-ObjC");
#else
// add HealthKit capability
Debug.Log("---ELSE BE:Capability UNITY_2019_3_OR_NEWER ---");
Debug.Log("projectPath:" + projPath);
Debug.Log("entitlementsRelative:" + entitlementsRelative);
Debug.Log("targetName:" + targetName);
ProjectCapabilityManager capabilities = new ProjectCapabilityManager(projPath, entitlementsRelative, targetName);
capabilities.AddHealthKit();
// add HealthKit Framework
proj.AddFrameworkToProject(mainTarget, "HealthKit.framework", true);
// Set a custom link flag
proj.AddBuildProperty(mainTarget, "OTHER_LDFLAGS", "-ObjC");
#endif
proj.WriteToFile(projPath);
}
}
// -------------------------------
internal static PlistDocument ProcessInfoPList(string path, bool addHealthRecordsCapability) {
string plistPath = Path.Combine(path, "Info.plist");
PlistDocument info = GetInfoPlist(plistPath);
PlistElementDict rootDict = info.root;
// // Add the keys
if (HealthKitBuildProcessor.shareString != null) {
rootDict.SetString("NSHealthShareUsageDescription", HealthKitBuildProcessor.shareString);
}
else {
Debug.LogError("unable to read NSHealthShareUsageDescription");
}
if (HealthKitBuildProcessor.updateString != null) {
rootDict.SetString("NSHealthUpdateUsageDescription", HealthKitBuildProcessor.updateString);
}
if (addHealthRecordsCapability) {
rootDict.SetString("NSHealthClinicalHealthRecordsShareUsageDescription", HealthKitBuildProcessor.clinicalString);
}
// Write the file
info.WriteToFile(plistPath);
return info;
}
internal static string ProcessEntitlements(string path, PBXProject proj, string target, PlistDocument info, bool addHealthRecordsCapability) {
string entitlementsFile;
string entitlementsRelative;
string entitlementsPath;
Debug.Log("PATH: " + path);
Debug.Log("TARGET: " + target);
String test= proj.GetUnityMainTargetGuid();
Debug.Log("TEST proj: " + test);
entitlementsRelative = proj.GetBuildPropertyForConfig(target, "CODE_SIGN_ENTITLEMENTS");
Debug.Log("entitlementsRelative: " + entitlementsRelative);
Debug.LogFormat("get build property [{0}, {1} = {2}]", target, "CODE_SIGN_ENTITLEMENTS", entitlementsRelative);
PlistDocument entitlements = new PlistDocument();
if (entitlementsRelative == null) {
string projectname = GetProjectName(info);
Debug.Log("projectname: " + projectname);
entitlementsFile = Path.ChangeExtension("Entitlements", "entitlements");
Debug.Log("entitlementsFile: " + entitlementsFile);
entitlementsRelative = Path.Combine(path, entitlementsFile);
Debug.Log("entitlementsRelative: " + entitlementsRelative);
entitlementsPath = Path.Combine(path, entitlementsRelative);
Debug.Log("entitlementsPath: " + entitlementsPath);
//proj.AddFileToBuild(target, proj.AddFile(entitlementsRelative, entitlementsRelative, PBXSourceTree.Source));
Debug.LogFormat("add build property [{0}, {1}] => {2}", target, "CODE_SIGN_ENTITLEMENTS", entitlementsRelative);
proj.AddBuildProperty(target, "CODE_SIGN_ENTITLEMENTS", entitlementsFile);
string newEntitlements = proj.GetBuildPropertyForConfig(target, "CODE_SIGN_ENTITLEMENTS");
Debug.Log("newEntitlements: " + newEntitlements);
Debug.LogFormat("=> {0}", newEntitlements);
}
else {
entitlementsPath = Path.Combine(path, entitlementsRelative);
Debug.Log("ELSE:entitlementsPath " + entitlementsPath);
}
ReadEntitlements(entitlements, entitlementsPath);
entitlements.root.SetBoolean("com.apple.developer.healthkit", true);
if (addHealthRecordsCapability) {
Debug.Log("addHealthRecordsCapability =TRUE ");
var healthkitAccess = entitlements.root.CreateArray("com.apple.developer.healthkit.access");
healthkitAccess.AddString("health-records");
}
SaveEntitlements(entitlements, entitlementsPath);
return entitlementsRelative;
}
// -------------------------------
internal static void ReadEntitlements(PlistDocument entitlements, string destinationPath) {
Debug.Log("READING Entitlements [ReadEntitlements]");
Debug.Log("READING from destinationPath [ReadEntitlements]"+ destinationPath);
if (System.IO.File.Exists(destinationPath)) {
try {
Debug.LogFormat("reading existing entitlements: '{0}'.", destinationPath);
entitlements.ReadFromFile(destinationPath);
}
catch (Exception e) {
Debug.LogErrorFormat("error reading from file: {0}", e);
}
}
}
internal static void SaveEntitlements(PlistDocument entitlements, string destinationPath) {
try {
Debug.Log("----SaveEntitlements---");
entitlements.WriteToFile(destinationPath);
}
catch (Exception e) {
Debug.LogErrorFormat("error writing to file: {0}", e);
}
}
internal static PlistDocument GetInfoPlist(string plistPath) {
// Get the plist file
PlistDocument plist = new PlistDocument();
plist.ReadFromFile(plistPath);
return plist;
}
internal static string GetProjectName(PlistDocument plist) {
string projectname = plist.root["CFBundleDisplayName"].AsString();
return projectname;
}
}
I don't know about Unity, but from Xcode when you add a capability for health kit it will update the entitlement file by itself
I am using Selenium WebDriver in C# and
I am trying to dynamically create a folder and save screenshots of failing tests to it.
Here I am running the group of test cases (Test Suite of 66 test cases).
After running the test suite I found few failed tests with GDI+ error and were not captured as a screenshot.
But when I run them individually most of the failed cases (GDI+ error) were passing except few.
Here is the code for creating a folder:
TestExecutionStartTime = DateTime.Now;
baseDirectory = AppDomain.CurrentDomain.BaseDirectory + #"\" + ConfigurationManager.AppSettings.GetValues("failedTests")[0];
Browser = ConfigurationManager.AppSettings["WebDriver"];
DirectoryInfo directory = new DirectoryInfo(baseDirectory);
DirectoryInfo[] subdirs = directory.GetDirectories();
if (System.IO.Directory.GetDirectories(baseDirectory).Length == 0)
{
screenshotDirectory = baseDirectory + #"\" + (DateTime.Now.ToString("yyyy_MM_dd_hh_mm") + "_" + Browser);
Directory.CreateDirectory(screenshotDirectory);
}
Here is the code for taking screenshot:
public void takeScreenshot(string filename)
{
string fname = filename + ".jpg";
string screenshot = screenshotDirectory + #"\" + fname;
Screenshot ss = ((ITakesScreenshot)WebDriver).GetScreenshot();
byte[] image = ss.AsByteArray;
using (MemoryStream ms = new MemoryStream(image))
{
Image i = Image.FromStream(ms);
i.Save(screenshot);
}
I assume that the error is at this i.Save(screenshot) call, but I was not able to resolve it.
I have reason to believe (from experience) that your issue comes about as a result of the stream being destroyed while it is being saved (the using statement).
Things to be aware of:
Write permissions wherever you are saving the image
Make sure the path is correct - this will throw a GDI+ exception and is very misleading, verify your path, try a temporary directory instead of creating your custom image directory to rule this one out.
Make sure the height of the image is not bigger than (65534px)
You can verify this by looking at the size:
var bitmapTemp = new Bitmap(stream);
Console.WriteLine(bitmapTemp.Height);
Here's some code that destroys the stream only after the image is saved:
public static Screenshot GetScreenshot(ChromeDriver driver)
{
Screenshot ss = ((ITakesScreenshot)driver).GetScreenshot();
return ss;
}
public static void SaveScreenshot(byte[] byteArray, string location)
{
var stream = new MemoryStream(byteArray);
var img = Image.FromStream(stream);
img.Save(location);
stream.Dispose();
}
And use the functions like so:
var path = AppDomain.CurrentDomain.BaseDirectory;
var ss = GetScreenshot(driver);
SaveScreenshot(ss.AsByteArray, path + "imagename.jpg");
Thanks for your inputs AntonB.
I have considered your points and tried differently and got the solution.
i have used [SetUpFixture], [OneTimeSetUp] and [OneTimeTearDown] to create folder only once and it solved the problem.
Here is the code:
[SetUpFixture]
public class Config
{
public Config()
{
}
public string baseDirectory;
public static string screenshotDirectory;
[OneTimeSetUp]
public void SetUp()
{
Console.WriteLine("Creating a folder to capture failed scenarios");
baseDirectory = AppDomain.CurrentDomain.BaseDirectory + #"\" + ConfigurationManager.AppSettings.GetValues("failedTests")[0];
string Browser = ConfigurationManager.AppSettings["WebDriver"];
screenshotDirectory = baseDirectory + #"\" + (DateTime.Now.ToString("yyyy_MM_dd_hh_mm") + "_" + Browser);
Directory.CreateDirectory(screenshotDirectory);
}
[OneTimeTearDown]
public void TearDown()
{
}
}
I'm trying to scroll through images in my app, but I'm having trouble figuring out how to populate my list. The images are named using numbers from 1.jpg upwards. If anyone could help it would be great.
async private void Exec()
{
// Get the file location.
StorageFolder appFolder = Windows.ApplicationModel.Package.Current.InstalledLocation;
string myImageFolder = (appFolder.Path + "\\Assets\\Images");
int imageNumber = 1;
List<Uri> fileList = new List<Uri>();
foreach (var fileItem in fileList)
{
string imageFileName = imageNumber + ".jpg";
Uri uri = new Uri(myImageFolder + "/" + imageFileName);
fileList.Add(uri);
image.Source = new BitmapImage(new Uri(uri.ToString()));
await Task.Delay(TimeSpan.FromSeconds(1));
imageNumber++;
}
}
UPDATE
I have tried to create a workaround and do this without the foreach statement but its crashing when testing if the next file exists: :(
async private void Exec()
{
// Get the file location.
string root = Windows.ApplicationModel.Package.Current.InstalledLocation.Path;
string path = root + #"\Assets\Images";
StorageFolder appFolder = await StorageFolder.GetFolderFromPathAsync(path);
int imageNumber = 1;
int test = imageNumber;
do
{
string imageFileName = imageNumber + ".jpg";
Uri uri = new Uri(path + "\\" + imageFileName);
image.Source = new BitmapImage(new Uri(uri.ToString()));
await Task.Delay(TimeSpan.FromSeconds(1));
test = imageNumber + 1;
imageNumber++;
string testFile = test + ".jpg";
Uri uri1 = new Uri(path + "\\" + testFile);
if (await appFolder.TryGetItemAsync(uri1.ToString()) != null)
{
test = 99999;
}
}
while (test != 99999);
}
Your list does not contain any items. Your foreach will never run, as there will be no entries in your list.
You need to go through all paths in myImageFolder-root and add those uris to the list, then you can just use them in a foreach to create images and set their source, for every uri in the list.
Also imageNumber is un-needed then as you will have the URIs.
Prep the list of URIs first, by traversing the folder. Then modify the existing foreach to use those to build image objects.
Also, refrain from adding to a collection WHILE iterating it...
I have this working, and not a single foreach was required :D Thanks #Richard Eriksson
async private void Exec()
{
// Get the file location.
string root = Windows.ApplicationModel.Package.Current.InstalledLocation.Path;
string path = root + #"\Assets\Images";
StorageFolder appFolder = await StorageFolder.GetFolderFromPathAsync(path);
int imageNumber = 1;
int test = imageNumber;
do
{
string imageFileName = imageNumber + ".jpg";
Uri uri = new Uri(path + "\\" + imageFileName);
image.Source = new BitmapImage(new Uri(uri.ToString()));
await Task.Delay(TimeSpan.FromSeconds(1));
test = imageNumber + 1;
imageNumber++;
string testFile = test + ".jpg";
if (await appFolder.TryGetItemAsync(testFile) != null)
{
test = 99999;
}
else
{
test = 1;
}
}
while (test == 99999);
}
I am trying to add Google Adsense to my MVC mobile web application. I'd like to implement the Google Adsense Mobile content ad code. The Scripting Language they have is asp 3.0. Is there an MVC helper I can use to display these ads on a MVC C# Razor page? I can't find anything about MVC and displaying web ads online at all. Would love some help, I am totally stuck.
If I use regular Adsense Javascript code. The code doesn't load when I click around the site. Only when I click refresh on the page.
A simple HtmlHelper translated from Adsense ASP sample :
public static class AdsenseHelper
{
public static MvcHtmlString Adsense(this HtmlHelper htmlHelper, string clientKey, string adSlot)
{
var context = htmlHelper.ViewContext.HttpContext;
var request = context.Request;
int googleTime = (DateTime.Now - new DateTime(1970, 1, 1)).Days;
var googleDt = (1000 * googleTime) + Math.Round(1000d * (DateTime.Now - DateTime.Today).Milliseconds);
var googleUserAgent = context.Server.UrlEncode(request.ServerVariables["HTTP_USER_AGENT"]);
var googleScheme = (string.Compare(request.ServerVariables["HTTPS"], "on") == 0) ? "https://" : "http://";
var googleAdUrl =
"http://pagead2.googlesyndication.com/pagead/ads?" +
"client=" + clientKey + // ca-mb-pub-0000000000000000
"&dt=" + googleDt +
"&ip=" + context.Server.UrlEncode(request.ServerVariables["REMOTE_ADDR"]) +
"&markup=xhtml" +
"&output=xhtml" +
"&ref=" + context.Server.UrlEncode(request.ServerVariables["HTTP_REFERER"]) +
"&slotname=" + adSlot + // 0000000000
"&url=" + context.Server.UrlEncode(googleScheme + request.ServerVariables["HTTP_HOST"] + request.ServerVariables["URL"]) +
"&useragent=" + googleUserAgent +
GoogleScreenRes(context.Request) +
GoogleMuid(context.Request) +
GoogleViaAndAccept(context, googleUserAgent);
using (var client = new System.Net.WebClient())
{
string result = client.DownloadString(googleAdUrl);
return new MvcHtmlString(result);
}
}
private static string GoogleColor(string value, int random)
{
var colorArray = value.Split(',');
return colorArray[random % (colorArray.Length)];
}
private static string GoogleScreenRes(HttpRequestBase request)
{
var screenRes = request.ServerVariables["HTTP_UA_PIXELS"];
char delimiter = 'x';
if (string.IsNullOrEmpty(screenRes))
{
screenRes = request.ServerVariables["HTTP_X_UP_DEVCAP_SCREENPIXELS"];
delimiter = ',';
}
if (string.IsNullOrEmpty(screenRes))
{
screenRes = request.ServerVariables["HTTP_X_JPHONE_DISPLAY"];
delimiter = '*';
}
if (screenRes != null)
{
string[] resArray = screenRes.Split(new[] { delimiter }, 2);
if (resArray.Length == 2)
{
return "&u_w=" + resArray[0] + "&u_h=" + resArray[1];
}
}
return string.Empty;
}
private static string GoogleMuid(HttpRequestBase request)
{
var muid = request.ServerVariables["HTTP_X_DCMGUID"];
if (!string.IsNullOrEmpty(muid))
{
return "&muid=" + muid;
}
muid = request.ServerVariables["HTTP_X_UP_SUBNO"];
if (!string.IsNullOrEmpty(muid))
{
return "&muid=" + muid;
}
muid = request.ServerVariables["HTTP_X_JPHONE_UID"];
if (!string.IsNullOrEmpty(muid))
{
return "&muid=" + muid;
}
muid = request.ServerVariables["HTTP_X_EM_UID"];
if (!string.IsNullOrEmpty(muid))
{
return "&muid=" + muid;
}
return string.Empty;
}
private static string GoogleViaAndAccept(HttpContextBase context, string googleUserAgent)
{
if (string.IsNullOrEmpty(googleUserAgent))
return string.Empty;
string googleViaAndAccept = string.Empty;
var via = context.Server.UrlEncode(context.Request.ServerVariables["HTTP_VIA"]);
if (!string.IsNullOrEmpty(via))
{
googleViaAndAccept = "&via=" + via;
}
var accept = context.Server.UrlEncode(context.Request.ServerVariables["HTTP_ACCEPT"]);
if (!string.IsNullOrEmpty(accept))
{
googleViaAndAccept = googleViaAndAccept + "&accept=" + accept;
}
return googleViaAndAccept;
}
}
This helper does not work with desktop browsers. But can be bypassed by changing the useragent as Opera Mini.
Like Google says :
AdSense for Mobile Content is only for use on websites designed with older feature phones in mind. As fully web-capable smartphones become more and more common, we recommend that you use AdSense for Content for all of your Content Ads needs.