I am running a PureScript app that is being served up by a backend Suave application in F#. In the front end, I need to open a WebSocket connection in PureScript to the backend, but part of the path needs to be dynamic based on how the backend app is running (for example on some boxes it is: ws://host1:9999/ws/blah, on others it might be ws://host2:7777/ws/blah).
So I need to get the current URL that my app is being served up on so that I can just put a ws:// on the front, and a ws/blah on the end (or somehow do a relative WebSocket path?).
I've tried doing something like:
wdw <- window
htmldoc <- document wdw
let doc = htmlDocumentToDocument htmldoc
docUrl <- url doc
connection <- WS.create (WS.URL $ "ws://" <> docUrl <> "ws/blah") []
But the document URL given has http:// on the front of it. I could hack up the string and rip that part out, but I'm hoping to find a more elegant way.
If it matters, I'm also using Halogen here so I have access to their API if there is something useful in there for this situation.
I was able to piece it together from stholzm's suggestion above.
In the documentation for location, there are functions for Hostname and Port that can be used to piece together the base url. The location can be obtained via the location function that takes in a window instance.
In the end, my code looks like
Related
I am actually trying to parse a website using the requests module, and extract some text out of it.
Url : https://www.icsi.in/student/Members/MemberSearch.aspx
after hitting the url in the Cp Number text field input : 16803
hit search,
on the bottom you can see some data, I want that data, let's say a name.
I am successfully able to get the data using selenium, but can't able to get it using requests module.
I have tried the requests module giving parameters, sessions, cookies etc.
but nothing worked.
url = "https://www.icsi.in/student/Members/MemberSearch.aspx"
ss = {'dnn$ctr410$MemberSearch$txtCpNumber':'16803',
'__EVENTTARGET':'dnn$ctr410$MemberSearch$btnSearch',
'__VIEWSTATEGENERATOR':'6A295697',
'dnn$ctlHeader$dnnSearch$Search':'SiteRadioButton'}
session = requests.Session()
cookies = session.cookies.get_dict()
for cookie in cookies:
session.cookies.set(cookie['name'], cookie['value'])
response = requests.post(url, data=ss)
print(response)
HTMLTree = html.fromstring(response.content)
name = HTMLTree.xpath('//div[#class="name_head"]//text()')
print(name)
I expect the output of the name of the person.
Anyone out there please help me.
If you don't mind using C# code I would be more than happy to help you otherwise it's a very lengthy process. If you choose that python is the only road you're willing to take then you should try grabbing the encrypted value within C:\User[USERNAME]\Appdata\Local\Google\Chrome\User Data\Default\Cookies You can change the file path accordingly to your OS. You can use SQLite to read and modify the encrypted values.
cookie = Decrypt(Encoding.Default.GetBytes(SQLDatabase1.GetValue(i, "encrypted_value")
if (cookie.Contains(".ASPXANONYMOUS")):
Step1 = cookie + "END"
Step2 = (step1 + ".ASPXANONYMOUS")
The following code above may help you with your journey.
I am using prawnpdf/pdf-inspector to test that content of a PDF generated in my Rails app is correct.
I would want to check that the PDF file contains a link with certain URL. I looked at yob/pdf-reader but haven't found any useful information related to this topic
Is it possible to test URLs within PDF with Ruby/RSpec?
I would want the following:
expect(urls_in_pdf(pdf)).to include 'https://example.com/users/1'
The https://github.com/yob/pdf-reader contains a method for each page called text.
Do something like
pdf = PDF::Reader.new("tmp/pdf.pdf")
assert pdf.pages[0].text.include? 'https://example.com/users/1'
assuming what you are looking for is at the first page
Since pdf-inspector seems only to return text, you could try to use the pdf-reader directly (pdf-inspector uses it anyways).
reader = PDF::Reader.new("somefile.pdf")
reader.pages.each do |page|
puts page.raw_content # This should also give you the link
end
Anyway I only did a quick look at the github page. I am not sure what raw_content exactly returns. But there is also a low-level method to directly access the objects of the pdf:
reader = PDF::Reader.new("somefile.pdf")
puts reader.objects.inspect
With that it surely is possible to get the url.
I'm new to use Testcomplete , i'm using javascripts to automate my code, below are sample script ( converted one recorded first then converted into jscript) and in this scripts what i observe that TestComplete identified and captured the object element by using complete web url path not on only object specific .
efunction Test_Login {var UserName, Password, TestEnv;UserName = "XYZ";Pwd = "XYZXYZ";TestEnv = "https://test.Env.com/";Browsers.Item(btChrome).Run("TestEnv",1);Aliases.browser.pageTestenvCom.formFrmlogincomponent.textboxUsername.SetText("UserName");Aliases.browser.pageTestenvCom.formFrmlogincomponent.passwordboxPassword.SetText("Pwd");Aliases.browser.pageTestenvCom.formFrmlogincomponent.buttonLogin.ClickButton();}e
what i means lets see below example of login page
thank you
Whenever we record any Test case in Test-Complete, it stores all the object in the Naming Repository and then access the same.
This helps test-complete in easily recognisation of object and can improve the speed of test-case, in case there are multiple objects visible on screen
You can go through following link for more info on Name Mapping.
https://support.smartbear.com/testcomplete/docs/testing-with/object-identification/name-mapping/overview.html
I am trying to create a load test versus one of our apps that is used on web and mobile. I am trying to access this app from the web. I login to the website. Using this login, I click on the web version of the app. The below response is returned here.
This app is using SiteMinder and Worklight to negotiate with the main site I am coming from.
My question is, how do I correlate a value such as 'SMIDENTITY=' when it is being returned TWICE in the same string?
Here is an example of what is being returned by the server (I have broken up the string so the variables are separated:
Test4.c(225):
Cookie:testcookie=oreo;
SMIDENTITY=Cq16kwJwrJWgBd5zQ8ci0kP8IEZ47kftOxMr1wVsxx+W/7sGS92ZA9zu69GRpolh0PRX97bvfHRya0m1ty1E07qR0HjKKXE8ypRsWPgG4m2w8mlspPUxL8t5Z4RE5/CCJpOxpXHIHeQK4f77gkihKFq8cBQr+Vy9kZGFGMUJH6+EiLNmmJT+XYZcUi7gzV0r+naJypMewtXAYaOcvn8Kqsu2JA5SiNUcJbxxX4dNCHOsC4cf45Jm0H40Efq6nOwN7MDyAE2gXSou4oa9ZlYxlsvWdEVl6CxgnqnqEkBJYVuBsgj/277+F7q9KB4xpct/sYvRT9CR/Rvh79hmpJJedH+lA8A6UtqyA21CnECQJzrbKJJgx3eeyN86BQv3g/kOWJ2CE4txEn22U+AjMKmxgB7fmLTNdxKS5+sn9P/Fs+TGwhRSX3pr/l1h4NQpNzb1Rz1fbt80/ODWbLSlBFBmQTCCRkLx54dcR40lH0iDl9543KZCAphpzKXS429ZZyCH00xdITd4vpab/l9cWZEHuoJFbgf4yWmx6eGo6zdPxb6Yv/D2EM9GnXnWsF14lrI4XtlreE+9o3EXSTbbz+MHh/ym/LzA4zaul4luiPMUNAnP+qatTR9WvK1NsC2KgsQl;
_ga=GA1.2.653519056.1433336304;
test_pol=UQEpK70TB9Ps6k9Zn0ZxC/WTTWAF7+1iJrMLhMAAA7SYUNDT9zue/krOWPgYi0yqdM6KUELeseH7xg==;
prismdc=prism1;
SMSESSION=CsYLjBNgLxl/cD1kJb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+nFGMIaCreNeu0Em+dY7rTU+KubyJqeYtt/NssB1Qq945MShkhix+KDKE+ViNmmyRqyUQpTEx6fXgbJQihm7KguDfOJSxvsalaO3vAwwN/mJTSxcRVktIaAYT4ZcakZS5r/mLRVllQmOczO4Ex2zAgflcEZ3GUlG3+TuL6JCYVWI3haAa0wUWffLCYRPo/n2+4vl5v/x9HkTXIZe0p4JCS1nWpzZXsg==;
LtpaToken=EHYGd9YV18oZsd8vSkJGm6EitmZCspgF2RbWMb/kDol6urQ8ZBeespgw8VR0jXPkwKdnAQjJ5x4ZdmTexnZiL3QIVzdH+DwWbTNP4KBAe/cdizYf8/0w05B9N13YX4rT7xl/Y0ZUhZX1brNgM7zP19a4IjL0E0M5uK2qah9ggErQhovcziPkA6Uubd4ne5keV/H/S0ZdaRMSjhXp6njlRtJl6C2U5r91YTXYVnbnl+sgG88g9jnPa6+peg+yi4P9VeoSohydoAIrqBGbpr7yL9ocaO3dL6bq/Ff6WAWZuca1V+7+x4bxtWHQ2CgafibbAkowunOsCyHvCRbv2FH8MQ==;
JSESSIONID=0000QLn5MU6tB5uMM0bXlOC8ZYS:15b4l3mm8;
SITE_ENTRY_JUMPTO=polhome;
scoreboard="";
scoreboardReport="";
WLSESSIONID=0000Xr6ZS67VI4UH-HoycrnVBq1:18lm04lom\r\n
Use the Ordinal (or index) number of the instance of the variable which you need as part of your collection
See training material or online help for correlation functions related to ordinal value
You didn't say what you're actually trying to do. Do you need only use the most recent? only use the first?
You use a web_reg_save_param_ex to capture all Ordinals of a parameter. It puts it into an array.
You can then do what you want with that array.
You can also use a web_reg_save_param_regexp
I coped the code from the official documentation and put your variable name in there to make it easier for you.
web_reg_save_param_ex(
"ParamName=SMIDENTITY",
"LB/IC=SMIDENTITY=",
"RB/IC=;",
"Ordinal=all",
LAST);
web_submit_data("...");
/* Getting individual elements from a parameter array.
Since the parameter created by web_reg_save_param_ex
is called "SMIDENTITY", the number of elements
is saved in parameter "SMIDENTITY_count".
The array elements are parameters "SMIDENTITY_1",
"SMIDENTITY_2", ... "SMIDENTITY_n".
*/
elemCnt = atoi(lr_eval_string("{SMIDENTITY_count}"));
lr_output_message("Number of items found = %d",elemCnt);
for (x=1;x<=elemCnt;x++) {
sprintf(arrayParamName, "{SMIDENTITY_%d}", x);
lr_output_message ("%s: %s",
arrayParamName,
lr_eval_string(arrayParamName));
}
I am trying to call the same link, but with different values, the issue is that the url is correct containing the new values but when I download it (Webclient.DownloadStringTaskAsync), it gives me the previous calls result.
I have tried adding headers no-cache, and attaching a random value to the call, and ifmodifiedSince header. however it is still not working.
any help will be much appreciated cause I have tried everything.
uri: + "&junk=" + Guid.NewGuid());
client.Headers["Cache-Control"] = "no-cache";
client.Headers[HttpRequestHeader.IfModifiedSince] = DateTime.UtcNow.ToString();
var accessdes = await client.DownloadStringTaskAsync(uri3);
so here my uri3 contains the latest values, but when I hover over accessdes, it contains the result as if I am making a old uri3 call with previous set data.
I saw one friend that was attaching a random GUID to the Url in order to prevent the OS to cache its content. For example:
if the Url were: http://www.ms.com/getdatetime and the OS is caching it.
Our solution was adding a guid for creating "sort of" like a new url, as an example our previous Url would look like: http://www.ms.com/getdatetime?cachebuster=21EC2020-3AEA-4069-A2DD-08002B30309D
(see more about cache buster : http://www.adopsinsider.com/ad-ops-basics/what-is-a-cache-buster-and-how-does-it-work/ )