I am trying to load https://www.paytm.com and search some products in webview but facing following problems in it.
1.It is not loading images in home page
2.If I search any products in search box window is getting stuck and not giving any results
3.if I click any product link, in status bar it showing as finished but nothing is displayed/rendered in page
private void Pageload() {
// Create a trust manager that does not validate certificate chains
TrustManager[] trustAllCerts = new TrustManager[] {
new X509TrustManager() {
public java.security.cert.X509Certificate[] getAcceptedIssuers() {
return null;
}
public void checkClientTrusted(
java.security.cert.X509Certificate[] certs, String authType) {
}
public void checkServerTrusted(
java.security.cert.X509Certificate[] certs, String authType) {
}
}
};
// Install the all-trusting trust manager
try {
SSLContext sc = SSLContext.getInstance("SSL");
sc.init(null, trustAllCerts, new java.security.SecureRandom());
HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
} catch (Exception e) {
System.out.println(e);
}
//now you can load the content:
String url = makeUrl(textField.getText()) ;
webView.getEngine().load(url);
textField.setText(url);
}
All other sites are working fine including google,gmail.
I am aware that the way I am creating trust manager to trust all is not a good practice, this is only for testing so I am doing it.
Related
I'm trying to navigate from a backdoor so that I can bypass a certain screen when running my UITests.
Here's my code:
AppDelegate.cs
[Export("bypassInitialGuidePage:")]
public NSString BypassInitialGuidePage(NSString noValue)
{
BackdoorHelpers.BypassInitialGuidePage();
return new NSString();
}
MainActivity.cs
[Export("BypassInitialGuidePage")]
public void BypassInitialGuidePage() => BackdoorHelpers.BypassInitialGuidePage();
BackdoorHelpers.cs
public static class BackdoorHelpers
{
#if DEBUG
public static void BypassInitialGuidePage()
{
new SettingsService().InitialGuideDone = true;
// Add navigation logic here
}
#endif
}
The BypassInitialGuidePage() method is being called successfully from the tests. However, I need help with getting the NavigationService so I can navigate away from current page.
I'm using Prism.Forms v7.1.0.431 and I've tried the solutions in https://github.com/PrismLibrary/Prism/issues/1032 but they are not working with the latest version.
i have implement all method for custome payment method , upload dll file to bin folder and check payment method in admin panel . paymet method appear in chekcout page but no one of my custom payment doesnt run . is there any full source of custom payment method in hotcakecommerce?
workfolw :
public class StartMyPaymentMethodCheckout : ThirdPartyCheckoutOrderTask
{
public override string PaymentMethodId
{
get { return MyPaymentMethod.Id(); }
}
public override bool ProcessCheckout(OrderTaskContext context)
{
if (context.HccApp.CurrentRequestContext.RoutingContext.HttpContext != null)
{
try
{
MyPaymentMethodSettings settings = new MyPaymentMethodSettings();
var methodSettings = context.HccApp.CurrentStore.Settings.MethodSettingsGet(PaymentMethodId);
settings.Merge(methodSettings);
// Here you can do custom processing of your payment.
// It can be direct post to payment service or redirection to hosted payment page
// In either case you have to end up on HccUrlBuilder.RouteHccUrl(HccRoute.ThirdPartyPayment) page
// So either you have to do such redirect here on your own
// or make sure that third party hosted pay page will make it in case of successfull or failed payment
HttpContextBase httpContext = new HccHttpContextWrapper(HttpContext.Current);
httpContext.Response.Redirect("http://www.google.com");
}
catch (Exception ex)
{
EventLog.LogEvent("My Custom Checkout", "Exception occurred during call to Moneris: " + ex.ToString(), EventLogSeverity.Error);
context.Errors.Add(new WorkflowMessage("My Custom Checkout Error", GlobalLocalization.GetString("MonerisCheckoutError"), true));
return false;
}
}
return false;
}
public override bool Rollback(OrderTaskContext context)
{
return true;
}
public override Task Clone()
{
return new StartMyPaymentMethodCheckout();
}
public override string TaskId()
{
return "E9B1A204-7C61-4664-A043-81BF43E24251";
}
public override string TaskName()
{
return "Start My ckout";
}
}
doesnt redirect to google.com
--Add New
why this code has not been overriden:
namespace MyCompany.MyPaymentMethod
{
public class MyCustomWorkflowFactory : WorkflowFactory
{
protected override Task[] LoadThirdPartyCheckoutSelectedTasks()
{
return new Task[]
{
new StartMyPaymentMethodCheckout()
};
}
}
}
i have checked both inheritance public class MyCustomWorkflowFactory : WorkflowFactory and public class MyCustomWorkflowFactory : dnnWorkflowFactory but none of them overiden on protected virtual Task[] LoadThirdPartyCheckoutSelectedTasks() , problem is there , I think !
Great question... Generally, if your breakpoint isn't getting hit, it's because you either haven't yet selected it yet in the Admin > Extensibility area, your code isn't yet deployed to where you're testing, or your code isn't following the prescribed pattern (all noted in the documentation).
Oh, and always make sure your web.config file is set to allow debugging like this.
<compilation debug="true" strict="false" targetFramework="4.0">
If you haven't already, you may want to check out the detailed documentation for deployment at https://hotcakescommerce.zendesk.com/hc/en-us/articles/204725899-Custom-Payment-Method-Example
I have written a windows service which in turn calls a web service. When I run the windows service from a test app., it works perfectly. However when I install the service and then start it, it stops almost immediately. The only two entries I see in the log are Constructor and Thread Started. Not sure what is wrong.
public partial class WindowsService : ServiceBase
{
public LogManager.LogFile _log;
public Thread m_thread;
protected TimeSpan m_delay;
CommonFunctions _cf = new CommonFunctions();
DBFunctions _db = new DBFunctions();
public WindowsService()
{
InitializeComponent();
_log = new LogManager.LogFile(#"c:\test\servicelog.txt", true, true);
_log.WriteToLog("Constructor", LogLevel.Level0);
}
protected override void OnStart(string[] args)
{
m_delay = new TimeSpan(0,0,300);
base.OnStart(args);
try
{
m_thread = new System.Threading.Thread(Execute);
m_thread.Start();
_log.WriteToLog("Thread Started", LogLevel.Level0);
}
catch (Exception ex)
{ _log.WriteToLog(ex.Message, LogLevel.Level0); }
}
public void Execute()
{
_log.WriteToLog("Begin Execute...", LogLevel.Level0);
try
{
ProcessNewLMSUsers();
}
catch (Exception ex)
{
_log.WriteToLog(ex.Message.ToString());
}
}
private void ProcessNewLMSUsers()
{
try
{
_log.WriteToLog("Begin: Processing new LMS Users", LogLevel.Level1);
// Check for new users in the LMS.
string callErrorText = "";
bool userAdded = false;
LMSWS.SSO lms = _cf.GetLMSSSOWS(); **// this is a web service**
lms.Timeout = 99999;
}
REST OF THE CODE.................
}
I can't see there is anything wrong with your code. but you can try to put a "Thread.Sleep(20000); " code at the begining of OnStart method. e.g.
protected override void OnStart(string[] args)
{
Thread.Sleep(20000);
m_delay = new TimeSpan(0,0,300); //set a break-point here
base.OnStart(args);
try
{
m_thread = new System.Threading.Thread(Execute);
m_thread.Start();
_log.WriteToLog("Thread Started", LogLevel.Level0);
}
catch (Exception ex)
{ _log.WriteToLog(ex.Message, LogLevel.Level0); }
}
and once you start this service program in Windows Service, then you have to quickly attach you source code to the service program. In visual studio, it's menu "Debug" -> "Attach to Process...". then you can set break-point in your source code anywhere to check what's going wrong.
Does anybody know of a tool, script, package, whatever that I can use to visit all pages in an ASP.NET Webforms web application project? (we aren't using any MVC functionality)
Preferably, I would like to be able to generate a list of URLs to hit, edit the list so I can add some query string params, hit all the pages in the list, and collect HTTP response codes: (200, 404, 500, 301, whatever).
Design time
Instead of using string literals for URLs in your application, define Url() methods in each page class like this:
public static string Url() { get { return "~/this_page.aspx"; } }
public static string Url(int ID) { get { return "~/this_page.aspx?id=" + ID; } }
Or list all URLs in a static class
public static class URL {
public static string Login() { get { return "~/login.aspx"; } }
public static string DisplayRecord(int recordID)
{ get { return "~/display.aspx?id=" + recordID; } }
Runtime
Use a web testing framework to crawl all links and edit the result. I blogged about one possible solution using Selenium.
I made a WinForms application that gets the pages that can be accessed from the .csproject and can open them by clicking a button.
using System;
using System.Collections.Generic;
using System.IO;
using System.Windows.Forms;
using System.Xml;
using System.Xml.XPath;
namespace OpenAllPages
{
public partial class Form1 : Form
{
public static IList<string> Pages;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
string xmlstring = ReadXml("TaskManager.csproj");
Pages = ParseAllPages(xmlstring);
pagesListBox.DataSource = Pages;
}
private string ReadXml(string location)
{
try
{
var myFile = new StreamReader(location);
string myString = myFile.ReadToEnd();
myFile.Close();
return myString;
}
catch (Exception e)
{
MessageBox.Show(String.Format("An error occurred: '{0}'", e.Message));
}
return null;
}
private IList<string> ParseAllPages(string xmlstring)
{
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml(xmlstring);
XPathNavigator nav = xmlDoc.DocumentElement.CreateNavigator();
XmlNamespaceManager manager = new XmlNamespaceManager(nav.NameTable);
manager.AddNamespace("x", "http://schemas.microsoft.com/developer/msbuild/2003");
var elements = nav.Select("x:ItemGroup/x:Content", manager);
var pageList = new List<string>();
while (elements.MoveNext())
{
var page = elements.Current.GetAttribute("Include", "");
if (page.EndsWith(".aspx"))
pageList.Add(page);
}
return pageList as IList<string>;
}
private string AddPagePrefix(string page)
{
return "http://localhost:8080/" + page;
}
private void openAllButton_Click(object sender, EventArgs e)
{
foreach (string page in Pages)
System.Diagnostics.Process.Start("chrome.exe", AddPagePrefix(page));
}
}
}
Here is a link to the code
You need to place the project file which contains the pages you want to open in the OpenAllPages project and set it's Copy to Output property to "Copy if newer".
I Form1_Load change TaskManager.csproj to the name of your project file.
And in:
System.Diagnostics.Process.Start("chrome.exe", AddPagePrefix(page));
rename parameter to the executable of the browser you are using.
I have the following HttpModule that I wanted to unit test. Problem is I am not allowed to change the access modifiers/static as they need to be as it is. I was wondering what would be the best method to test the following module. I am still pretty new in testing stuff and mainly looking for tips on testing strategy and in general testing HttpModules. Just for clarification, I am just trying to grab each requested URL(only .aspx pages) and checking if the requested url has permission (for specific users in our Intranet). So far it feels like I can't really test this module(from productive perspective).
public class PageAccessPermissionCheckerModule : IHttpModule
{
[Inject]
public IIntranetSitemapProvider SitemapProvider { get; set; }
[Inject]
public IIntranetSitemapPermissionProvider PermissionProvider { get; set; }
public void Init(HttpApplication context)
{
context.PreRequestHandlerExecute += ValidatePage;
}
private void EnsureInjected()
{
if (PermissionProvider == null)
KernelContainer.Inject(this);
}
private void ValidatePage(object sender, EventArgs e)
{
EnsureInjected();
var context = HttpContext.Current ?? ((HttpApplication)sender).Context;
var pageExtension = VirtualPathUtility.GetExtension(context.Request.Url.AbsolutePath);
if (context.Session == null || pageExtension != ".aspx") return;
if (!UserHasPermission(context))
{
KernelContainer.Get<UrlProvider>().RedirectToPageDenied("Access denied: " + context.Request.Url);
}
}
private bool UserHasPermission(HttpContext context)
{
var permissionCode = FindPermissionCode(SitemapProvider.GetNodes(), context.Request.Url.PathAndQuery);
return PermissionProvider.UserHasPermission(permissionCode);
}
private static string FindPermissionCode(IEnumerable<SitemapNode> nodes, string requestedUrl)
{
var matchingNode = nodes.FirstOrDefault(x => ComparePaths(x.SiteURL, requestedUrl));
if (matchingNode != null)
return matchingNode.PermissionCode;
foreach(var node in nodes)
{
var code = FindPermissionCode(node.ChildNodes, requestedUrl);
if (!string.IsNullOrEmpty(code))
return code;
}
return null;
}
public void Dispose() { }
}
For other people still looking there is this post which explains a way to do it
Original page was deleted, you can get to the article here:
https://web.archive.org/web/20151219105430/http://weblogs.asp.net/rashid/unit-testable-httpmodule-and-httphandler
Testing HttpHandlers can be tricky. I would recommend you create a second library and place the functionality you want to test there. This would also get you a better separation of concerns.