Unable to instantiate the URL - appium-android

I have written the first code for mobile automation, but stuck while instantiating the URL. Getting error
"URL can not be resolved to a type"
driver=new AndroidDriver<MobileElement>(new URL("http://127.0.0.1:4723/wd/hub"),cap);

First, make sure you have correct import of URL class:
import java.net.URL;

Related

Flutter 'get method was call on nul' Error

I was doing news app on Flutter and I was working with non-null safety because I was doing the older project.But then I started getting errors and I change my version to make the app with null-safety. Anyways, I changed the version re-edit the code I was thinking that I did great work but suddenly I'm getting this error right now. How can I fix this?
in your import do like below.
import 'package:http/http.dart' as http;
call your response like below...
http.Response response = await http.get(
endPointUrl,
);
As of my knowledge we cant declare http with var....thats why its shows error...above code will work

Card widget gives error when I use fluter_stripe payment method in same page

I am using flutter_stripe lib for integrating the Stripe payment method but it gives an error when I use Card widget with this lib.
My error is given as:
"The name 'Card' is defined in the libraries 'package:flutter/src/material/card.dart (via package:flutter/material.dart)' and 'package:stripe_platform_interface/src/models/payment_methods.dart'.\nTry using 'as prefix' for one of the import directives, or hiding the name from all but one of the imports.",
I found its answer by modifying the flutter_stripe import as
import 'package:flutter_stripe/flutter_stripe.dart' hide Card;

Hosting a Telethon User BOT on google-app-engine

I am trying to deploy a simple user bot on Google App Engine Flexible Environment running python3.7, but I get the following error. Can anyone help me with suggestions of solving this?
"File "/env/lib/python3.7/site-packages/telethon/client/auth.py", line 20, in phone: typing.Callable[[], str] = lambda: input('Please enter your phone (or bot token): '), EOFError: EOF when reading a line"
Thank you for your time
Telethon (obviously) requires you to login and make a normal user session on your account, which natively requires you to input your number when asked and enter the code received but since Google App engine doesn't allow input as #Sashidhar mentioned, depending on your userbot implementation, you can try using the userbot.session method for authentication, it can be generated locally and placed in the Google App Engine.
I try to use python on app engine to call telethon functions, upon deploy the app. I receive the Internal Server Error from browser.
I am seeing you are success on this road, would you mind shine a light on this to help me starting up, such as how to configue the app.yaml, main.py, requirements.txt , .... or any proper arrangement of librarys to make this work.
much much thanks in advance.
following is my main.py which raised server internal error on brows, the problem does not happen if this first telethon related line is remarked:
client = TelegramClient(phone, api_id, api_hash)
main.py
--------
from flask import Flask, request
import datetime
import time
import asyncio
from telethon import TelegramClient, events, sync
app = Flask(__name__)
api_id = xxxxxxxx
api_hash = 'xxxxxxxxxxxxxxxxxxxxxxxx'
phone = '+xxxxxxxxxxxx'
#app.route('/', methods=['GET'])
def hello():
reqaction = request.args.get('action', 'connect')
client = TelegramClient(phone, api_id, api_hash)
if __name__ == '__main__':
app.run(host='localhost', port=8080, debug=True)
would you mind shine a light on this to help me starting up, much thanks
I am now able to host my user BOT on GAE using the session string login method.
https://docs.telethon.dev/en/latest/concepts/sessions.html#string-sessions

Angular JS 2 route with sails js

I'm trying to set up a sails js app with Angularjs 2 in front.
I Want to use the angularJS system routing and no sails js system.
How can I disable the sails route and let angular control them ?
This is my app.component.ts where I declare the route /account
import {View, Component} from 'angular2/core';
import {RouteConfig, ROUTER_DIRECTIVES} from 'angular2/router';
import {AccountComponent} from './account.component';
#Component({
selector: 'my-app',
template: `<router-outlet></router-outlet>`,
directives: [ROUTER_DIRECTIVES]
})
#RouteConfig ([
{path: '/account', name: 'Account', component: AccountComponent}
])
export class AppComponent {
}
If I remove the route in config/routes.js, this doesn't work.
I try to disable some options in config.blueprint.js but nothing good.
I want to use Angular route to have an SPA and don't reload pages.
Thanks.
In fact, it's normal that you have an error when trying to access route directly without having a configuration on the server. In fact the actual address of a route is updating (and without # / hashbang approach) by Angular2 without any interaction with the server when using a route. The path doesn't exist on the server. If you load the HTML entry point file, everything will work fine. The only problem is when you try to access directly a route from its path...
By default, HTML5 history is used by Angular2. If you want not having this problem, you need to update your server to serve the index.html file for each route path you defined.
If you want to switch to the HashBang approach, you need to use this configuration:
import {bootstrap} from 'angular2/platform/browser';
import {provide} from 'angular2/core';
import {ROUTER_PROVIDERS} from 'angular2/router';
import {LocationStrategy, Location, HashLocationStrategy } from 'angular2/router';
import {MyApp} from './myapp';
bootstrap(MyApp, [
ROUTER_PROVIDERS,
provide(LocationStrategy, {useClass: HashLocationStrategy}
]);
In this case, when you refresh the page or access directly the page, it will be displayed again (but you will have a # in your address).
This link could help you as well:
Angular 2 : 404 error occur when i refresh through Browser
Hope it helps you,
Thierry
I have to return "/" for all routes in config/routes.js and let angular to display others view.

Scraping data out of facebook using scrapy

The new graph search on facebook lets you search for current employees of a company using query token - Current Google employees (for example).
I want to scrape the results page (http://www.facebook.com/search/104958162837/employees/present) via scrapy.
Initial problem was facebook allows only a facebook user to access the information, so directing me to login.php. So, before scraping this url, I logged in via scrapy and then this result page. But even though the http response is 200 for this page, it does not scraps any data. The code is as follows:
import sys
from scrapy.spider import BaseSpider
from scrapy.http import FormRequest
from scrapy.selector import HtmlXPathSelector
from scrapy.contrib.spiders import CrawlSpider, Rule
from scrapy.contrib.linkextractors.sgml import SgmlLinkExtractor
from scrapy.selector import HtmlXPathSelector
from scrapy.item import Item
from scrapy.http import Request
class DmozSpider(BaseSpider):
name = "test"
start_urls = ['https://www.facebook.com/login.php'];
task_urls = [query]
def parse(self, response):
return [FormRequest.from_response(response, formname='login_form',formdata={'email':'myemailid','pass':'myfbpassword'}, callback=self.after_login)]
def after_login(self,response):
if "authentication failed" in response.body:
self.log("Login failed",level=log.ERROR)
return
return Request(query, callback=self.page_parse)
def page_parse(self,response):
hxs = HtmlXPathSelector(response)
print hxs
items = hxs.select('//div[#class="_4_yl"]')
count = 0
print items
What could I have missed or done incorrectly?
The problem is that search results (specifically div initial_browse_result) are loaded dynamically via javascript. Scrapy receives the page before those actions, so there is no results yet there.
Basically, you have two options here:
try to simulate these js (XHR) requests in scrapy, see:
Scraping ajax pages using python
Can scrapy be used to scrape dynamic content from websites that are using AJAX?
use the combination of scrapy and selenium, or scrapy and mechanize to load the whole page with the content, see:
Executing Javascript Submit form functions using scrapy in python
this answer
If you go with first option, you should analyze all requests going during the page load and figure out which one is responsible for getting the data you want to scrape.
The second is pretty straightforward, but will definitely work - you just use other tool to get the page with loaded via js data, then parse it to scrapy items.
Hope that helps.