load several classes. How to use Restler3 AutoLoader? - autoloader

FIRST :
Thank you for this great "Restler" !
MY CONTEXT :
I use Restler 3 to build my own API and return the total score of my users (on games).
Example : "www.mysite.com/api/score/12345" => Return the total score (json object) of user id "12345"
But, to get the total score (from the different games), i need to use my own library (called "scorers") and its classes :
- vendor/damGames/scorers/scoreGameA.class.php
- vendor/damGames/scorers/scoreGameB.class.php
- vendor/damGames/scorers/scoreGameC.class.php
- etc...
MY QUESTION IS :
To load the classes of my library, should i use the "Luracast\Restler\AutoLoader" ? I don't understand how... Else, how can i do ?
Thank you !

The only solution I found :
In the first lines of my Restler class called "Score", I put :
use Luracast\Restler\RestException;
use damGames\scorers\scoreGameA;
use damGames\scorers\scoreGameB;
use damGames\scorers\scoreGameC;
...
It's a good way to do ? Have you something better ?

Related

how can i find xpath or CSS selector for only ''Total Cases'' in the following table (url =this https://www.worldometers.info/coronavirus/ )

I tried several types of XPath but none of those working as I want to
Xpath : //td[#class='sorting_1'],
xpath: //tr[contains(#class,'even')]//td[#class='sorting_1'],
xpath : //tr[contains(#class,'odd')]//td[#class='sorting_1']
CSS: .even+ .odd .sorting_1 , .even .sorting_1
but the CSS selector does not work in the scrappy shell
can you please help me out of this situation??
To get total cases by country, just use :
//table[#id='main_table_countries_today']//td[contains(#style,'text-align:left;')][normalize-space()]/following-sibling::td[1]
To get the country names :
//table[#id='main_table_countries_today']//td[contains(#style,'text-align:left;')][normalize-space()]
Output (219 lines):
Side note : normalize-space is used to filter "the ghost" line present in the table (no country name and a value of 721). Probably a leftover of and old "Diamond Princess" record.
EDIT : In fact 721 corresponds to the total number of cases on the two ships ( Diamond Princess and MS Zaandam)
EDIT : If you want to get the data for each country (ships and World included) located on the first tab only (213 nodes) :
//table[#id='main_table_countries_today']//td[contains(#style,'text-align:left;')][parent::tr[not(#style="display: none")]]/following-sibling::td[1]
To exclude the ships (211 nodes) :
//table[#id='main_table_countries_today']//td[contains(#style,'text-align:left;')][parent::tr[not(#style="display: none")]][not(./span)]/following-sibling::td[1]
To exclude ships and World (210 nodes) :
//table[#id='main_table_countries_today']//td[contains(#style,'text-align:left;')][parent::tr[not(#style="display: none")]][./a[#href]]/following-sibling::td[1]
Hey try using this expression for xpath:
(//div[#class='maincounter-number']/span)[1]/text()
for css:
response.css('#maincounter-wrap:nth-child(7) span::text')

How to solve dynamic xpath ( id chagned after exceute )

I got problem such as :
id="tabscontent:tabView:BWconent_0:j_idt670"
After exceute
id changed = "tabscontent:tabView:BWconent_0:j_idt682"
670 change 682
Everyone know how to make : contains() or starts-with() or ends-with()
Please to help me
Thank you so much
P/s : I mean using xpath id for Katalon Testcase
Assuming that the beginning part of the id is static you can use starts-with() like this:
//*[starts-with(#id, 'tabscontent:tabView:BWconent_0:treeLeft_0:1:j_idt')]
The above XPath will return elements with id attribute value starts with "tabscontent:tabView:BWconent_0:treeLeft_0:1:j_idt"
Use this
TestObject myObject = new TestObject().addProperty('css', ConditionType.EQUALS, 'a[id^="tabscontent:tabView:BWconent_0"]')
The ^="some text" denotes "starts-with" for css selectors.
You will need to import TestObject and ConditionType classes. You can just press Ctrl+Shift+O in script mode and Katalon will do the rest.

Passing two variables in a ForEach controller in jmeter

I am running a ForEach controller in which I want the controller to run the service underneath it for changes in sets of latitudes and longitudes. example-
Input variable prefix: latitude
Output variable name: Latitude
I want to run the controller for changes in both "latitude" and "longitude". I tried doing this-
Input variable prefix:latitude, longitude
but it does not work. Is there any other way to pass two variables in ForEach controller?
Unfortunately you cannot do it using ForEach Controller, but you can work it around using __V() and __counter() function combination.
For example you have 4 JMeter Variables:
latitude_1=40.7128° N
longitude_1=74.0059° W
latitude_2=32.0853° N
longitude_2=34.7818° E
And you want to iterate them both using ForEach Controller. In that case the relevant configuration would be:
Input variable prefix: latitude
Output variable name: anything meaningful, i.e. current_latitude
You can refer matching longitude value using the following expression:
${__V(longitude_${__counter(,)})}
Demo:
See Here’s What to Do to Combine Multiple JMeter Variables for detailed explanation of where did the above expression come from.
I encountered same problem and google a lot to find the best possible solution but
did not get success. I am sharing my work-around (and I am not saying it's a great solution ) -
Mention your Input variable name (ex - inputVar) as well as Output variable name (outputVar) on ForEach Controller
(lets say http://website.com/folder_A/folder_B/123_latitude/456_longitude) and you like to take care these two : latitue and longtitude
Use regular expression extractor :
Name of created variable : inputVar
Expression : http://website.com/folder_A/folder_B/(.*)
Template : $1$
match No : -1 // (yes -1 , this will give you complete group)
Handle with regular expression (just search it out )
so for above example : that would be -
http://website.com/folder_A/folder_B/${outputVar}
http://website.com/folder_A/folder_B/${outputVar} URL will be able to print / give you latitue and longtitude in your response code

Suggestions on how to create an user-friendly UI for a builder expression(if statements ,mathematical and logical operations)

I need to create a builder expression in asp.net that allows users to create and edit expressions like this
If ([age] >=60 : 50; If ([age]>=50 : 40; If ([age]>=40 : 30; If([age]>=30 : 20;0))))
or its more readable equivalent :
If ([age] >=60 : 50) Else If ([age]>=50 : 40) Else If ([age]>=40 : 30) Else If ([age]>=30 : 20) Else 0
I know how to run code on the fly and I also have a few ideas on how to convert these strings into a .net code, the problem I'm facing now , is how to design an UI that lets users edit this sort of expressions with the minimum margin of error.
I had thought of using a dropdownlist with all the variables defined by the user , another one for the available operators, but I'm not so sure, that's why I want to ask you guys if you have ever done something similar or have any ideas on how to do this
Any advise or guidance would be greatly appreciated.

Bizarre problem with CodeIgniter routing rules

I have set two rules :
$route['followers/(:num)'] = 'hall/filter/subscribers/$1';
And :
$route['see/(:num)'] = 'hall/see/$1';
But while the first one is working all fine, the second one behaves juste like the 2nd argument (the :num) wasn't passed at all (displaying see/4 gives the hall/see/ page, not hall/see/4 !). This is very odd because from my point of view, those 2 routes work the same way !!
Any idea ?
Edit :
If I change $route['see/(:num)'] to $route['foo/see/(:num)'] then it works. This is crazy oO
You should use "" instead '', so it should be
$route['followers/(:num)'] = "hall/filter/subscribers/$1";
$route['see/(:num)'] = "hall/see/$1";

Resources