how to check RSelenium navigate function returned proper page - rselenium

I've found some inconstistency in the RSelenium navigation function. Namely, I've started just the server this way:
rS <- rsDriver(browser = "phantomjs", port = 4567L, check = T)
rDr <- rS[['client']]
rDr$navigate(yahoo)
doc <- rDr$getPageSource()
and navigated to the Yahoo page. And everything is ok, but while I try to do it once again (this or other page from Yahoo) it returns very similar page, but this seems like some scripts haven't been loaded. While I renew it once or twice or trice this works again. My idea is there's some checker when you want to load the resource from the server too quickly. If so, how to handle this programically? I haven't found any methods in documentation something like isPageLoadedProperly() or so. I can set some timeout but don't know how long, is it constant value and many other questions. Anyone had that issue before?

Related

Get Page url on block types

I am working on generating a report in episerver in the form of a scheduled job.This report is basically used to get all the contents(page types,blocks,media) within Episerver.
There are some good nuget packages for content usages but for some reason& to have more control & plans for tweeking & extending it further,i am creating a custom one rather than using the available 3rd party packages.
The scheduled job is kind of similar to
https://www.codeart.dk/blog/2018/12/content-report-generator/ .
The article helped me a lot to get my report working with some modifications as per my requirement.
The one thing that I am struggling here is to get the URL of where the block is. Now this is a point of debate here.
I am aware that the blocks being shared in nature can be used anywhere in a site but the point is they are still used in pages or as a matter of fact in other blocks which is turn is used on a page.What i am trying to say here is,they directly or indirectly are part of a page.So is there a way to get the page url of a block irrespective of how many pages they are in.
Every forum I have looked at ,there's always page url of Pagedata or mediadata & nothing on blockdata.Even 3rd party nuget packages that i have looked for does not have page url for block types.
I do understand that there is nothing out of the box here.Is there a way to achieve this ie get the page url of a specific block type which can be a list of page urls if the block is used in multiple pages.
Recursive function to reach the page:
private string GetPublicUrl(IContentRepository contentRepository, IContentSoftLinkRepository contentSoftLinkRepository, ContentReference contentReference)
{
var publicUrl = string.Empty;
var content = contentRepository.Get<IContent>(contentReference);
var referencingContentLinks = contentSoftLinkRepository.Load(content.ContentLink, true)
.Where(link => link.SoftLinkType == ReferenceType.PageLinkReference && !ContentReference.IsNullOrEmpty(link.OwnerContentLink))
.Select(link => link.OwnerContentLink);
foreach (var referencingContentLink in referencingContentLinks)
{
publicUrl = UrlResolver.Current.GetUrl(referencingContentLink.GetPublicUrl()) ?? GetPublicUrl(contentRepository, contentSoftLinkRepository, referencingContentLink);
}
return publicUrl;
}
I have written this recursive function to reach the page ,but this works only when there is a single level. For instance A 2Col block on a page.
If I have a block say Download Block which is on a 2Col block which in turn is on a page ,then in this case the url is empty.
Any input is appreciated.
With IContentSoftLinkRepository you can find where the blocks are used. You can check whether the SoftLink points to a page with SoftLink.SoftLinkType == PageLinkReference and then use IUrlResolver to get the page's URL.

Identity Server 4 AuthorizationContext.PromptModes empty

I am using the oidc-client library to authorize with our own Identity Server 4. It is working fine and I need to extend the login functionality. I'd like to use the OIDC-Parameter "prompt". The parameter is sent correctly to the connect/authorize endpoint. When the Login-Method is called, I am trying to get the AuthorizationContext by calling
var context = await _interaction.GetAuthorizationContextAsync(vm.ReturnUrl);
var prompt = context.PromptModes;
_interaction is an instance of IIdentityServerInteractionService. The PromptModes are always empty. Is this the right way I am trying to access them?
Thank you
It looks like you check the value in an inappropriate place.
The answer for a similar question on Github was:
we have to remove the prompt parameter because we would otherwise run into an endless loop. You could save the parameter in a separate parameter I guess.

Retrieving the route parameter in Next 9 when loading a page directly?

I'm trying the get the route parameter in Next 9 and all the examples in the docs make sense and work. Here https://nextjs.org/learn/basics/clean-urls-with-dynamic-routing/dynamic-routing and here https://nextjs.org/docs#imperatively
My problem is that these examples are all in the context of navigating to a page from a link, I would like to load the page directly from the url.
If I go to localhost:3000/meeting/123 it loads the index page, not teh page nested in the meetings folder.
The query parameter shows the 'asPath' key with eth value 'meeting/123' so its all working but it doesn't actually use the code at pages/meeting/[meetingId].js
How do I load a dynamic route directly from the url?
For anyone else reading this, this works absolutely fine, false alarm, I just forgot to remove my customer server setup that I had for this previously. To do this prior to next 9 you had to set up a custom server and startup using the server. I set everything up for version 9 but was still starting up in teh custom server. Leaving this up here in case anyone else makes teh same mistake.

Access Functions and controls on a Silverlight Page

I am kind of new to Silverlight and I am having some issues. I have been trying to figure this out for a few hours now...
I have a main page that waits for a packet from a server. When that packet arrives it is handled in a module. Depending on the packet data the module handles an action. Some of those actions involve subroutines on the main page. I access them via:
Dim MainPage As MainPage = App.Current.RootVisual
If strPacketData(1) = "0" Then
MainPage.Do_Sign_In(True, strPacketData(2))
Else
MainPage.Do_Sign_In(False, strPacketData(2))
End If
And this works fine.
Assuming the sign in works the main page calls
Me.Content = New Page2
And the page switches to Page2
The problem is that the same code doesn't work when trying to access subs and controls on page2.
If I try:
Dim Page2 As Page2 = App.Current.RootVisual
If strPacketData(1) = "1" Then
Page2.lblCreateError.Opacity = 100
End If
I get Unable to cast object of type 'SLClient.MainPage' to type 'SLClient.Page2'.
What I am getting from this is that App.Current.RootVisual is set to MainPage, but MainPage shouldn't be open...
I have tried setting App.Current.RootVisual to Page2 but that doesn't seem to do anything.
I am hoping that this issue is caused by my ignorance of silverlight and that there is an easy fix for this...
I guess what I need to do is detect which page is currently being displayed and manipulate the controls and functions\subroutines on that page.
Any Input would be greatly appreciated.
OK well I finally figured it out. Or at least I figured out a way to do it.
I used a dictionary to store the addresses of the pages once they were created in memory. I also modified the program so that rootVisual is its own grid instead of a page. Now the grid loads and clears the pages as children.
I don't know... Silverlight is kind of screwy. Whatever, it works now.

Is this a Bot modifying my URLs for some tracking purpose?

I don't know if this is bad code on our part, or a bot/spider doing something for tracking purposes. What I'm seeing is our URLs are getting modified, and it's generating site errors and error emails that I'm set up to get when it seems like my site is being hacked.
For example, a URL that should read/load like this
http://site.com/page.asp?pid=915411&order=Date
gets loaded like this
http://site.com/page.asp?pid=-1'&order=Date
the email I get shows
query string = pid=-1%27&order=Date
The IP address that comes up in the error emails always change, but many point to Kiev or Minsk, but are so varied I don't see how I can stop this from happening easily. My site is on an IIS 7.5 server, win2008.
Someone is trying to hack your application. They are testing if your application uses values from the forms or URL directly into SQL statements.
This hacking attempt is easy and called "SQL injection". Check your application if it is vulnerable, fix it immediately if required.
Additionally, try to track the attackers and if you see them coming from a set of IP addresses, block them.
Using HTTP_REEFER we are able to control the URL Modifying on directly.
Try the below code
if Request.ServerVariables("HTTP_REFERER") = "" Then
RESPONSE.WRITE " <b><h1><font color=blue></font><font color=red>UNSECURED MENU ACCESS</font><font color=blue></font><h1></b> "
response.end
End if

Resources