I have tried it a lot but not able to figure out why my tests are not running on Browser Stack.
1 - Package that i have installed
nativescript-dev-appium
Steps that i have done successfully are as follows:
1 - APK uploaded to Browser Stack.
2 - Used command to run test: npm run e2e android.
Below are the processes which happens successfully on browser stack but at last point it always timeout.
Initializing Device
00:14
1
Downloading App
00:14
6
Installing App
00:14
3
Setting Up Appium
00:14
1
Setting Up Network Connection
00:21
7
Launching App
01:53
0
STOP SESSION
IDLE TIMEOUT
Code is as follows:-
var wd = require('wd');
var assert = require('assert');
var asserters = wd.asserters;
var capabilities = {
'device' : 'Samsung Galaxy S8',
'os_version' : '7.0'
}
Object.assign(capabilities, {
'browserstack.user' : 'nitintayal1',
'browserstack.key' : 'WhpbGSn97yyy2HSY3XtN',
'project': 'My First Project',
'build' : 'My First Build',
'name': 'Bstack-[Node] Sample Test',
"app" : "bs://ee1e2103d4826968e28630ccee562059ec10fadd",
"automationName":"UIAutomator2"
});
let driver = wd.promiseRemote("http://hub-cloud.browserstack.com/wd/hub");
driver
.init(capabilities)
//Write your code here
.then(function(){
assert(true);
})
.fin(function() { return driver.quit(); })
.done();
Related
Good morning!
I have a strange problem where i can run & authenticate my user on my ios device perfectly fine running the app using the command below.
ionic capacitor run -l --external
Using an emulator, it works sometimes, though not always.
When I try to deploy the app using Xcode, the app opens and looks normal, but if I try to send authentication requests to firebase, the app just keeps on loading, although the requests are successfully performed.
I first thought the problem was because of using LocalStorage so I rebuilt everything using Ionic Storage. But that didn't help.
I tried different versions of adding the Firebase SDK in Swift or in the Cocoa Pods file but the behaviour doesn't change so I don't believe that this is a issue with a wrong firebase configuration, what is the proper way to do this by the way - or is Ionic doing this for me already?
The output of Xcode doesn't provide any valuable information either.
2021-12-01 11:20:13.990875+0100 App[3162:27661] Writing analzed variants.
2021-12-01 11:20:14.125754+0100 App[3162:27661] KeyboardPlugin: resize mode - native
⚡️ Loading app at capacitor://localhost...
2021-12-01 11:20:14.552490+0100 App[3162:27661] Writing analzed variants.
⚡️ WebView loaded
⚡️ [log] - Angular is running in development mode. Call enableProdMode() to enable production mode.
⚡️ [log] - null
⚡️ To Native -> App addListener 60635511
2021-12-01 11:20:21.393141+0100 App[3162:27661] [Accessibility] WKContentView[#] set up: # pid: # MACH_PORT -830404096
login-function
loginWithEmail() {
let email: string = this.loginForm.get("email").value;
let password: string = this.loginForm.get("password").value;
this.loadingService.present({
message: "Logging in . . ."
});
this.authService
.loginWithEmail(email, password)
.then((result) => {
this.authService.SetUserData(result.user)
this.resetLoginForm();
this.loginSuccess();
this.router.navigateByUrl("/tabs/intensity");
})
.catch(error => {
console.log(error);
this.loginFailed(error);
});
}
login-success
loginSuccess() {
this.loadingService.dismiss();
this.toastService.present({
message: "Welcome back!",
duration: 3000,
color: "secondary"
});
}
login-with-email
import { AngularFireAuth } from "#angular/fire/compat/auth";
...
async loginWithEmail(email: string, password: string) {
return await this.afAuth.signInWithEmailAndPassword(email, password);
}
set user-data function
SetUserData(user) {
this.user = user;
const userRef: AngularFirestoreDocument<any> = this.afs.doc(`users/${user.uid}`);
const userData: User = {
uid: user.uid,
email: user.email,
displayName: user.displayName,
photoURL: user.photoURL,
emailVerified: user.emailVerified
}
return userRef.set(userData, {
merge: true
})
}
Running it multiple times some times I get this error.
API error: <_UIKBCompatInputView: 0x7fb965726040; frame = (0 0; 0 0); layer = <CALayer: 0x600002f718a0>> returned 0 width, assuming UIViewNoIntrinsicMetric
I am really stuck on this and would appreciate any help. Thank you & kind regards.
Ionic 6.18.1
Angular 12.1.5
Xcode Version 13.1 (13A1030d)
I am following the firebase docs for implementation of Cloud Messgaing.
Receiving and handling messages while my ionic app is in the background works fine but when handling same in foreground I am running into issues.
This is the code:
PushNotifications.addListener('pushNotificationReceived',
(notification : PushNotificationSchema) => {
alert("Push received while app open: " + JSON.stringify(notification));
const title = notification.notification.title;
const body = notification.notification.body;
const page = notification.notification.data.department;
alert ("Notification: department = " + page + " Title : " + title);
//console.log("NOTIFICATION REC IN APP FOREGROUND: " + title + " AND BODY : " + body);
if (page){
this.router.navigate(['/'+page]);
}
},
);
The first alert with details of the notification executes every time, but nothing after.
In the Xcode console I see an error but there is no description:
Any idea what the issue might be with my ionic code or how to determine the error thrown in Xcode would be appreciated.
Hope this is helpful for some as I found there are allot of potential answers out there but the only solution I found is as follows:
Add this to the capacitor.config.json of your Ionic project:
"plugins": {
"PushNotifications": {
"presentationOptions": ["badge", "sound", "alert"]
}
}
Then build / synch your ionic app:
ionic build
ionic cap sync
See Capacitor Docs here for more details.
1.Open the MS Chromium edge and type the command "edge://settings/help" to check the version
2. Download the MS Chromium edge webdriver and placed it into project directory
3. Set the desired capabilities in conf.js file
4. Start the server using command "webdriver-manager start --edge msedgedriver.exe"
5. Run the test using the "protractor conf.js"
Environment:
Chromium Edge Version = 83.0.478.37
Chromium web driver = 83.0.478.37
Selenium server version = 3.141.59
JDK =1.8.191
conf.js
exports.config = {
// The address of a running selenium server.
seleniumAddress: 'http://localhost:4444/wd/hub',
capabilities: {
'browserName': 'chrome',
'goog:chromeOptions': {
// Faked out chrome binary
'binary':'C:\\Program Files (x86)\\Microsoft\\Edge Beta\\Application\\msedge.exe'
}
},
//Path of Chromium edge driver
chromeDriver:'./msedgedriver.exe',
specs: ['spec.js'],
}
};
Also tried with using desired capabilities in spec.js file as well but still blank page is opened
describe('slow calculator', function() {
beforeEach(function() {
let options = new edge.Options();
options.setEdgeChromium(true);
//options.setBinaryPath("C:\\Program Files (x86)\\Microsoft\\Edge Beta\\Application\\msedge.exe");
let browser = edge.Driver.createSession(options);
browser.get('http://juliemr.github.io/protractor-demo/');
});
});
While starting webdriver-manager, ensure the path to msedgedriver is specified.
webdriver-manager start --edge "pathToEdgeDriver/msedgedriver.exe"
The capabilities object should have MicrosoftEdge as browserName.
seleniumAddress: 'http://localhost:4444/wd/hub',
capabilities: {
'browserName': 'MicrosoftEdge'
}
I'm trying to run browserstack behind the firewall.
I tried to run this command on terminal:
RK$ ./BrowserStackLocal --key <key> --force-local
BrowserStackLocal v7.0
You can now access your local server(s) in our remote browser.
Press Ctrl-C to exit
I opened another terminal and I ran the command
npm run test:functional:cr:mobile
I get the following error:
1) Run sample test flow page:
Uncaught WebDriverError: [browserstack.local] is set to true but local testing through BrowserStack is not connected.
This is my config.js
'use strict'
import webdriver from 'selenium-webdriver'
let driver
module.exports = {
getDriverConfiguration: function (testTitle, browserName) {
var capabilities = {
'browserName': process.env.BROWSER || 'Chrome',
'realMobile': 'true',
'os': 'android',
'deviceName': process.env.DEVICE || 'Samsung Galaxy S8',
'browserstack.user': 'USER',
'browserstack.key': 'KEY',
'browserstack.debug': 'true',
'build': 'Build for mobile testing',
'browserstack.local' : 'true',
'browserstack.localIdentifier' : 'Test123'
}
driver = new webdriver.Builder().withCapabilities(capabilities).usingServer('http://hub-cloud.browserstack.com/wd/hub').build()
driver.manage().deleteAllCookies()
return driver
}
}
I enabled browserstack.local to true but I still get this error.
Not sure where I'm going wrong.
Please kindly help.
The error [browserstack.local] is set to true but local testing through BrowserStack is not connected. is returned if your BrowserStackLocal connection (the one you established using ./BrowserStackLocal --key --force-local) is disconnected.
I would suggest you use the following approach instead, to avoid the additional step and easily manage your local testing connection:
npm install browserstack-local
Once you have installed the browserstack-local module, use the following code snippet as reference to modify your code and start browserstack-local from your code itself(before the line driver = new webdriver.Builder().withCapabilities(capabilities).usingServer('http://hub-cloud.browserstack.com/wd/hub').build()), instead of starting it from a separate terminal window:
var browserstack = require('browserstack-local');
//creates an instance of Local
var bs_local = new browserstack.Local();
// replace <browserstack-accesskey> with your key. You can also set an environment variable - "BROWSERSTACK_ACCESS_KEY".
var bs_local_args = { 'key': '<browserstack-accesskey>', 'forceLocal': 'true' };
// starts the Local instance with the required arguments
bs_local.start(bs_local_args, function() {
console.log("Started BrowserStackLocal");
});
// check if BrowserStack local instance is running
console.log(bs_local.isRunning());
// stop the Local instance
bs_local.stop(function() {
console.log("Stopped BrowserStackLocal");
});
I'm new to Protractor.
I'm declaring an element as a variable like :
txtSearch : element(by.xpath('//input[#type="search"]')),
In some point I want to log the locator as :
var clickOn = function(webElement)
{
webElement.click();
console.log("Successfully clicked on the " + webElement);
};
I'm calling this function from Spec file like - clickOn (txtSearch)
In Console.log I am getting like - Successfully clicked on the [object Object].
Please find the required details below :
Node Version: 7.5.0
Protractor Version: 5.1.1
Browser(s): Chrome
Protractor configuration file :
exports.config = {
capabilities: {
browserName: 'chrome',
},
onPrepare: function(){
jasmine.getEnv().addReporter(reporter);
global.isAngularSite = function(flag) {
browser.ignoreSynchronization = !flag;
};
browser.manage().timeouts().setScriptTimeout(60000);
browser.driver.manage().window().maximize();
},
seleniumServerJar: '../../protractor/selenium/selenium-server-standalone-2.52.0.jar',
chromeDriver: '../../protractor/selenium/chromedriver_2.27.exe',
directConnect: true,
framework: 'jasmine2',
seleniumAddress: 'http://localhost:4444/wd/hub',
specs: ['../PoC_Protractor/spec.js'],
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 600000,
isVerbose: true
}
I tried with webElement.locator().toString() but it is throwing-
Failed: webElement.locator is not a function
You can always output the locator used using webElement.locator().toString(). Check the output for the below code snipper.
Protractor spec:
describe('Locator testing by model', function(){
it('automate user register form', function(){
browser.get('http://www.way2automation.com/angularjs-protractor/registeration/#/login');
var search = element(by.model('Auth.user.name'))
console.log(search.locator())
console.log("Successfully clicked on the " + search.locator().toString());
console.log(search.locator().toString())
});
});
Output:
[14:01:48] I/local - Starting selenium standalone server...
[14:01:48] I/launcher - Running 1 instances of WebDriver
[14:01:49] I/local - Selenium standalone server started at http://10.96.61.119:56341/wd/hub
Started
{ findElementsOverride: [Function], toString: [Function] }
Successfully clicked on the by.model("Auth.user.name")
by.model("Auth.user.name")
.
1 spec, 0 failures
Finished in 0.942 seconds
[14:01:53] I/local - Shutting down selenium standalone server.
[14:01:53] I/launcher - 0 instance(s) of WebDriver still running
[14:01:53] I/launcher - internet explorer #01 passed
Hey it seems like you may not be resolving the promise in the correct way, try using -
webElement.click().then(function(element){
console.log(""Successfully clicked on the " + element);
};