I'm facing a problem while executing my test cases for a native app. The thing is when I launch Chrome then the flow is like Accept & Continue > Next > No Thanks > url to my web app.
Sometimes the Next screen is missing and the No Thanks screen is displayed.
I tried using if-else, and or conditions but they didn't work out for me
from appium import webdriver
from time import sleep
desired_cap = {
"platformName": "Android",
"platformVersion": "8.1",
"deviceName": "emulator-5554",
"appPackage": "com.android.chrome",
"appActivity": "com.google.android.apps.chrome.Main",
"automationName": "Appium",
"appReset": "true"}
driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub', desired_cap)
driver.implicitly_wait(30)
driver.find_element_by_xpath("//android.widget.Button[#text='ACCEPT & CONTINUE']").click()
choices = driver.find_element_by_xpath("//android.widget.Button[#text='NEXT'] or //android.widget.Button[#text='NO THANKS'][1]").click()
try this :
from appium import webdriver
from time import sleep
desired_cap = {
"platformName": "Android",
"platformVersion": "8.1",
"deviceName": "emulator-5554",
"appPackage": "com.android.chrome",
"appActivity": "com.google.android.apps.chrome.Main",
"automationName": "Appium",
"appReset": "true"}
driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub', desired_cap)
driver.implicitly_wait(30)
driver.find_element_by_xpath("//android.widget.Button[#text='ACCEPT & CONTINUE']").click()
time.sleep(4)
try :
driver.find_element_by_xpath([#text='NEXT']).click()
except :
pass
driver.find_element_by_xpath(Button[#text='NO THANKS']).click()
Related
Spark - Databricks jobs fail occasionally due to slow cluster library import. The notebook execution starts before the library is fully initialized and the entire process fails. If the same notebook is executed shortly after the failure, import proceeds successfully w/o any other intervention needed.
I was trying using try/catch approach, but the imported objects are unsurprisingly available only within the try block:
var tries = 0
var importSuccessful = false
while(!importSuccessful && tries < 3){
try {
import org.fde.dataFoundation.helper
import org.fde.dataFoundation.transactionMapping._
importSuccessful = true
} catch{
case e:Exception => println("Write failed with error: " + e.getMessage)
tries += 1
if(tries >= 3) {
throw new Exception(s"FD&E Data Foundation library couldn't be imported after ${tries - 1} attempts. Check if library ocrDataFoundationS3 is installed on the cluster")
}
Thread.sleep(5*60*1000) //wait 5 minutes
}
}
Could you please recommend an option how to execute try/catch cycle and make the library available for the entire netbook?
Note: the internal process rules require use of libraries installed on VC.
I have web server written in golang which uses graphql package gqlgen and gorm for database.
Since golang can be compiled and run on android I wanted to create offline version of my app where sqlite can be used for offline storage and import my whole server as an aar.
I have successfully built aar and add it on my flutter using gomobile by following instructions here
When I run my app, server is started on android it seems to work just fine and when opening http://localhost:8080/ on emulator's chrome app I am seeing graphql playground runs without any problem just like I see on browser in windows.
The only problem I face is that flutter app just shows a blank screen while server runs in background. The following are the logs printed when app is started
Launching lib\main.dart on sdk gphone64 x86 64 in debug mode...
Running Gradle task 'assembleDebug'...
√ Built build\app\outputs\flutter-apk\app-debug.apk.
Installing build\app\outputs\flutter-apk\app.apk...
Debug service listening on ws://127.0.0.1:62561/DyGpOhyuekw=/ws
Syncing files to device sdk gphone64 x86 64...
I/GoLog ( 6295): connect to http://localhost:8080/ for GraphQL playground
W/ux.offline( 6295): type=1400 audit(0.0:38): avc: denied { read } for name="somaxconn" dev="proc" ino=74990 scontext=u:r:untrusted_app:s0:c149,c256,c512,c768 tcontext=u:object_r:proc_net:s0 tclass=file permissive=0 app=com.nux.offline
I think maybe problem lies on the above logs avc: denied { read } for name="somaxconn" or something is causing the blocking of ui thread since its like flutter don't render a thing.
I am using flutter plugin to start server and this is ServerPlugin.kt
package com.mahesabu.server.server
import androidx.annotation.NonNull
import io.flutter.embedding.engine.plugins.FlutterPlugin
import io.flutter.plugin.common.MethodCall
import io.flutter.plugin.common.MethodChannel
import io.flutter.plugin.common.MethodChannel.MethodCallHandler
import io.flutter.plugin.common.MethodChannel.Result
import lib.Lib.startServer
/** ServerPlugin */
class ServerPlugin : FlutterPlugin, MethodCallHandler {
/// The MethodChannel that will the communication between Flutter and native Android
///
/// This local reference serves to register the plugin with the Flutter Engine and unregister it
/// when the Flutter Engine is detached from the Activity
private lateinit var channel: MethodChannel
override fun onAttachedToEngine(#NonNull flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) {
channel = MethodChannel(flutterPluginBinding.binaryMessenger, "server")
channel.setMethodCallHandler(this)
}
override fun onMethodCall(#NonNull call: MethodCall, #NonNull result: Result) {
if (call.method == "startServer") {
try {
val port = startServer() //from golang bindings
result.success(port)
} catch (e: Exception) {
e.printStackTrace();
result.error("Error in starting server", "${e.message}", null);
}
} else {
result.notImplemented()
}
}
override fun onDetachedFromEngine(#NonNull binding: FlutterPlugin.FlutterPluginBinding) {
channel.setMethodCallHandler(null)
}
}
And this is is dart code
class Server {
static const MethodChannel _channel = MethodChannel('server');
static Future<String?> startServer() async {
try {
final String? port = await _channel.invokeMethod('startServer');
return port;
} catch (e) {
log('startServer error: ${e.toString()}');
return null;
}
}
}
and my app's main is as follows
import 'package:flutter/material.dart';
import 'package:server/server.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
final port = await Server.startServer(); //problem
print('port $port'); //This don't print
runApp(const MyApp());
}
On go side this how i start server
//start.go
package util
import (
"github.com/99designs/gqlgen/graphql/handler"
"github.com/99designs/gqlgen/graphql/playground"
"log"
"my-project/graph"
"my-project/graph/generated"
"net/http"
"os"
)
const defaultPort = "8080"
// StartServer This way so that it can be invoked via libs
func StartServer(Offline bool) string {
port := os.Getenv("PORT")
if port == "" {
port = defaultPort
}
db := InitDB(Offline)
config := generated.Config{Resolvers: &graph.Resolver{
DB: db,
}}
srv := handler.NewDefaultServer(generated.NewExecutableSchema(config))
http.Handle("/", playground.Handler("GraphQL playground", "/query"))
http.Handle("/query", srv)
log.Printf("connect to http://localhost:%s/ for GraphQL playground", port)
log.Fatal(http.ListenAndServe(":"+port, nil))
return port
}
and this is lib for generating bindings with gomobile
//lib.go
package lib
import "my-project/util"
// StartServer This way so that it can be invoked via libs
func StartServer() string {
return util.StartServer(true)
}
Any help on fixing this will be appreciated.
Edit
I think problem occurs when embedded server tries to create a new port. I don't know if it is possible for an app to open a new port in android just like nodejs, golang open things like http://localhost:8080.
Now I think if there is a way to create port then I can run my app successfully but I don't know how exactly.
I was thinking if I can find any available port on android and use to start server maybe this stack could be possible. In kotlin something like this may work in finding port.
import java.net.ServerSocket
fun main() {
val serverPort = ServerSocket(0)
print(serverPort.toString())
}
but it crashes on android app when I try similar thing.
I have uploaded a repository on GitHub showing what I intend to do. It's just a simple golang server using gin and android app (with no flutter) it is available here.
"I don't know if it is possible for an app to open a new port in android just like nodejs, golang open things like localhost:8080"
To find out the root cause, try to run an HTTP server in android, such as How to create a HTTP server in Android?. If that succeeds, try to find the differences about how they deal with ports.
In addition, please be sure you have correct permission in androidmanifest.xml.
(Rephrased from my comments)
I have a few questions regarding IOBluetooth framework which are listed below.
I currently have one MacBook Pro (13-inch, 2018) running Big Sur v11.1 and when I call inquiries and attempt to find nearby devices it often fails and does not work consistently. On the other hand, I have a second MacBook Pro (13-inch, 2015) running Mojave v10.14.6 which does the exact same functions and always works each time. I have also been testing using blueutil command line tool: https://github.com/toy/blueutil as well as PyBluez: https://github.com/pybluez/pybluez and find that my second MacBook running Mojave always finds nearby devices while the MacBook running Big Sur has trouble doing so. Do you know if this is because of potential updates to the framework or is there something wrong with my laptop running Big Sur?
I am trying to open L2CAPChannel from my first laptop to the second and vice versa but calling openL2CAPChannelSync on the IOBluetoothDevice object (which I have instantiated properly) seems to never return kIOReturnSuccess. Am I doing something wrong here as well? I attached a snippet of the code (in which I removed the addressString of my other device) I am using below.
import IOBluetooth
import PlaygroundSupport
class ChannelDelegate : IOBluetoothL2CAPChannelDelegate {
func l2capChannelOpenComplete(_ l2capChannel: IOBluetoothL2CAPChannel!, status error: IOReturn) {
print("Channel Opened!")
}
}
var remoteDevice = IOBluetoothDevice(addressString: ***deviceString***)
print((remoteDevice?.name ?? "nil") as String)
remoteDevice?.openConnection()
var connection = remoteDevice?.isConnected()
print(connection!)
var channelPtr: AutoreleasingUnsafeMutablePointer<IOBluetoothL2CAPChannel?>?
var success = remoteDevice?.openL2CAPChannelSync(channelPtr, withPSM: 0x0000, delegate: ChannelDelegate())
print(success == kIOReturnSuccess)
PlaygroundPage.current.needsIndefiniteExecution = true
In regards to the second point, I fixed the code and is pasted below. The issue was that Apple's documentation stated that the object is instantiated using the function call openL2CAPChannelSync but that is not the case. You need to instantiate the object first then pass a reference to the object you instantiated. Hope this saves people some time given how little examples there are on IOBluetooth API.
import IOBluetooth
import PlaygroundSupport
class ChannelDelegate : IOBluetoothL2CAPChannelDelegate {
func l2capChannelOpenComplete(_ l2capChannel: IOBluetoothL2CAPChannel!, status error: IOReturn) {
print("Channel Opened!")
}
}
var remoteDevice = IOBluetoothDevice(addressString: ***deviceString***)
print((remoteDevice?.name ?? "nil") as String)
remoteDevice?.openConnection()
var connection = remoteDevice?.isConnected()
print(connection!)
var channel: IOBluetoothL2CAPChannel? = IOBluetoothL2CAPChannel()
var success = remoteDevice?.openL2CAPChannelSync(&channel, withPSM: 0x0000, delegate: ChannelDelegate())
print(success == kIOReturnSuccess)
PlaygroundPage.current.needsIndefiniteExecution = true
I'm trying to write an Eclipse plugin which gets all current running LaunchConfigurations (run- and debugmode ones) and terminates them from the back (see img. 1.1).
I know, that there is a terminate() method within the class ILaunchConfiguration, but I don't think that this is what I'm looking for.
[img. 1.1]
here is an example of LaunchConfigurations (the second and the third are in debugmode), that I want to terminate from last to first.
Any help is appreciated as always!
Get the list of current launches from the launch manager and terminate the active processes.
Something like:
ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
ILaunch [] launches = manager.getLaunches();
for (ILaunch launch : launches) {
IProcess [] processes = launch.getProcesses();
for (IProcess process : processes) {
if (process.canTerminate()) {
process.terminate();
}
}
}
While working on some projects, I would sometimes prefer to disable by the auto-reloading feature of Play (and only reload manually).
Is there a way to quickly achieve this? (Other than typing start at the play prompt, which adds some overhead as it packages the app.)
Create a new Scala app that will start the Play app:
import play.api.{Application, ApplicationLoader, Environment, Mode, Play}
import play.core.server.{ServerConfig, ServerProvider}
object MyPlayApp extends App {
val config = ServerConfig(mode = Mode.Dev)
val application: Application = {
val environment = Environment(config.rootDir, this.getClass.getClassLoader, Mode.Dev)
val context = ApplicationLoader.createContext(environment)
val loader = ApplicationLoader(context)
loader.load(context)
}
Play.start(application)
val serverProvider: ServerProvider = ServerProvider.fromConfiguration(this.getClass.getClassLoader, config.configuration)
serverProvider.createServer(config, application)
}
Then run it: sbt "runMain MyPlayApp"