Access Selenium LocalStorage nodejs - node.js

Im trying to retrieve a value from a key using selenium, i've been searching for hours without anybody or anything telling me how i could do that,
What im trying to retrieve looks like this which i obtained while typing F12 : https://i.imgur.com/xYSHnnC.png
Which is on the client side.

You can use this:
driver.executeScript(
"localStorage.getItem(arguments[0])", key
);

Try this:
window.localStorage.getItem("BrowserHandoffStore");
Example here:
window.localStorage.setItem("test", false);
window.localStorage.getItem("test")
Output:
false

for who maybe still are looking for the solution:
you can use web driver executeScript
async function(localStorageFieldName){
await driver.executeScript(function(){
return localStorage.getItem(arguments[0])
},localStorageFieldName)
}
reference to executeScript : link

Related

Method to clear pre-filled data of a ST.future.Component

Is there a way to clear an input field while using the ST.component("locator"); API?
Using ST.component("locator").setValue(""); results in the following error:
TypeError: ST.component(...).setValue is not a function...
PS: Is the old forum now permanently closed? Is there a way to view older questions?
Edit: Seems like the other forum was down yesterday, therefore the PS.
If it's an Ext JS field you will need to use the ST.field API in Sencha Test, which has a setValue method. This method isn't available on the more generic ST.component API.
ST.field('myfield')
.setValue('');
Or if it's a normal input field (not an Ext JS component), then you can do the following:
ST.element('#myfield')
.execute(function(field) {
field.dom.value = '';
});

Integrate GeeTestTask(python3_anticaptcha) with selenium in python3

I have a problem about python3_anticaptcha (api provided by anti-captcha.com), search on web, find support and try over a month but no luck.
API doc:
https://anticaptcha.atlassian.net/wiki/spaces/API/pages/416972814/GeeTestTaskProxyless+-+captcha+from+geetest.com+without+proxy
I am doing a auto login on a website, and copy the api on anti-captcha's doc:
def runGee(self, challenge):
print("start gee")
try:
# Enter the key to the AntiCaptcha service from your account. Anticaptcha service key.
ANTICAPTCHA_KEY = "mycode"
# обязательные параметры
websiteURL = "https:\/\/www.nike.com.hk"
gt = "2328764cdf162e8e60cc0b04383fef81"
print("sloving1")
print("challenge:" ,challenge)
# пример работы с GeeTestTask без прокси
result = GeeTestTaskProxyless.GeeTestTaskProxyless(anticaptcha_key=ANTICAPTCHA_KEY,
websiteURL=websiteURL,
gt=gt).captcha_handler(challenge=challenge)
print("sloving2")
print(result)
print("--end gee--")
except Exception as err:
print(err)
print("--end with error--")
However, the geetask start over 3 minute(or more), and got error everytime. usually error code like:
{'errorId': 34, 'errorCode': 'ERROR_TOKEN_EXPIRED', 'errorDescription': 'Captcha provider
reported that additional variable token has expired.', 'taskId': 1204556667}
or
{'errorId': 12, 'errorCode': 'ERROR_CAPTCHA_UNSOLVABLE', 'errorDescription': ' Captcha
could not be solved by 5 different workers.', 'taskId': 1204060350}
..etc
depends on what parameter i passed.
May i know am i passing the right value to geetask? or some wrong on the code?
Moreover, if geetest return the correct value, i need to do any else to pass capcha(or pass code to geetest server) or GeeTestTaskProxyless already done(not to do anything)?
it is extremely hard to me, does anyone had used this api successfully? Thanks
The problem is not in the anticaptcha but in the geetest provider.
The token challenger can only be used once, when your browser loads the geetest captcha it expires the token.
To fix this problem, you only need to block the request that consumes the token in your browser.
go to devtools and add the block for the geestest captcha API in the browser, like this:
You can automatically integrate this into the selenium with the following command:
driver.execute_cdp_cmd('Network.setBlockedURLs', {"urls": ["api.geetest.com/get.php"]})
driver.execute_cdp_cmd('Network.enable', {})
It seems for me that those errors are because of proxy (if you use any) or just bad IP.
Personally, I use another captcha service and I didn't have such problems with it.
I advice you to try it, it's actually much easier: https://2captcha.com/2captcha-api#solving_geetest
You should send a request like this one:
https://2captcha.com/in.php?key=1abc234de56fab7c89012d34e56fa7b8&method=geetest&gt=f1ab2cdefa3456789012345b6c78d90e&challenge=12345678abc90123d45678ef90123a456b&api_server=api-na.geetest.com&pageurl=https://www.example.com/page/
What you need to archieve is to get correct answer from it, like this one:
{
"challenge":"1a2b3456cd67890e12345fab678901c2de",
"validate":"09fe8d7c6ba54f32e1dcb0a9fedc8765",
"seccode":"12fe3d4c56789ba01f2e345d6789c012|jordan" }
Then you just need to implement that answer on a site. Just read the first link I gave you.
Cheers.

Is there a way to get the current browser name using selenium web-driver (nodejs)?

I tried doing driver.getBroswerName(), but it didnt recognize the function getBrowerName()?. I guess there is not that function. So is there any other way to get the current browser name?
Try this.
driver.getCapabilities().then(function (caps) {
console.log(caps.get("browserName"));
});

Youtube API search auto-complete

I'm using Youtube API, I'd like to have a search auto-complete feature, just like on YouTube, when you type into the search input box, it gives you search suggestions.
I've read the docs, but still missing, Is this possible using the API?
Ok I found this URL:
http://suggestqueries.google.com/complete/search?client=firefox&ds=yt&q=Query
It isn't part of Youtube API, but still works, returns a JSON response.
For json just add "client" parameter:
http://suggestqueries.google.com/complete/search?client=youtube&ds=yt&client=firefox&q=Query
Above all apis are old and give google search suggestion not youtube search suggestion
Use this:
https://clients1.google.com/complete/search?client=youtube&gs_ri=youtube&ds=yt&q=faded
Extract suggestions using following JS code:
// data is response of above api
const data = 'window.google.ac.h(["faded",[["faded",0,[433]],["faded alan walker lyrics",0,[433]],["faded remix",0,[433]],["faded 8d",0,[433]],["faded piano",0,[433]],["faded wheel free fire",0],["faded karaoke",0,[433]],["faded ringtone",0,[433]],["faded instrumental",0,[433]],["faded live",0,[433]],["faded piano tutorial",0,[433]],["faded whatsapp status",0,[433]],["faded dhol cover",0,[433]],["faded dance",0,[433]]],{"k":1,"q":"_sPyvXmmbfcsVtfP4sgjOdKQAvg"}])';
const searchSuggestions = [];
data.split('[').forEach((ele, index) => {
if (!ele.split('"')[1] || index === 1) return;
return searchSuggestions.push(ele.split('"')[1]);
});
console.log(searchSuggestions);
Check Out YouTube AutoComplete Keyword Scraper . Not really sure of the context the person asking the question wants YouTube auto complete solution for but I thought I would throw this out there.
Also you can use JSON:
url: "https://suggestqueries.google.com/complete/search?client=youtube&ds=yt&q=" + i,
dataType: "jsonp",
The official one:
https://suggestqueries-clients6.youtube.com/complete/search?client=youtube-reduced&hl=en&gs_ri=youtube-reduced&ds=yt&cp=3&gs_id=100&q=Nectar&xhr=t&xssi=t&gl=us
You can choose country too.
P.S. I searched for Nectar in country US

MgTwitterEngine Iphone

Hello
I am using mgtwitterengine in iphone to call twitter API. I want to retrive followers name
in my iphone.
I used textfield.text=[_engine getFollowersIncludingCurrentStatus:YES]; but it is not showing correct result. it only show some alphabets...
could anyone tell me how to do this.
you are using
NSLog(#"%#",[_engine getFollowersIncludingCurrentStatus:YES]);
getFollowersIncludingCurrentStatus not responding the result, it returns connection identifier which is DF387EE5-05CE-40E3-A12D-4D016C581233 in your case
your API response will come in this method
- (void)userInfoReceived:(NSArray *)userInfo forRequest:(NSString *)identifier
this is delegate method you have to add this in your class.
[_engine getFollowersIncludingCurrentStatus:YES];
use like this it may help you, i got the values and printing on console

Resources