Unable to access Remote Webdriver to Browserstack using Codeception - php

I am Writing scripts for Browserstack using PHP Codeception.
Here it is my acceptance.yml file
modules:
enabled:
- WebDriver
config:
WebDriver:
url: 'http://www.google.com'
host: 'hub.browserstack.com'
port: 80
browser: Android
device: Samsung Galaxy S5
deviceOrientation: portrait
capabilities:
'browserstack.user': 'USERNAME'
'browserstack.key' : 'ACCESS_KEY'
'browserVersion': '21.0'
'browserstack.debug': 'true'
But after run the program through the command line, it will be displaying as below error message in command prompt.
**[Facebook\WebDriver\Exception\UnknownServerException]
Session terminated**
I will change some script like url: 'http://localhost:8080' and 'browserstack.local': 'false' From the above acceptance.yml file.
Then Error being displayed as "Unable to Connect to Server"
Can anyone please give some suggestion to resolve this problem.

You need to set the capabilities as follows when executing a test on Android emulators (Samsung Galaxy S5) on BrowserStack:
config:
WebDriver:
url: 'http://www.google.com'
host: 'hub.browserstack.com'
port: 80
browser: android
capabilities:
'browserstack.user': '<username>'
'browserstack.key' : '<automate-key>'
'device': 'Samsung Galaxy S5'
'platform': 'ANDROID'
Note: 'android' for browser needs to be all lower case and for platform all upper case.
The Code Generator can be very helpful to specify the capabilities while testing on different browser and OS combinations especially mobile devices.
If you wish to access your local servers on BrowserStack, such as 'http://localhost:8080', you can follow these steps:
a) Setup a Local Testing connection using the binaries.
b) Add the capability 'browserstack.local': 'true' in your scripts.

Related

Run tests using Behat and Mink Selenium2 driver for Microsoft Edge browser in Selenium 4

Is it possible to run tests on Edge browser using Mink Selenium2 driver and Selenium 4 grid ?
I've tried using:
default:
suites:
default:
filters:
tags: ~#wip
paths: ['%paths.base%/storage/features']
gherkin:
cache: ~
extensions:
Behat\MinkExtension:
base_url: http://www.google.com
javascript_session: selenium2
browser_name: edge
selenium2:
capabilities:
browserName: MicrosoftEdge
browser: edge
extra_capabilities:
edgeOptions:
args:
- "--no-sandbox"
- "--disable-dev-shm-usage"
- "--headless"
- "--disable-gpu"
- "--dns-prefetch-disable"
- "--disable-setuid-sandbox"
- "--window-size=1920,1080"
- "--remote-debugging-port=9222"
But this gives me some errors saying that the DevToolsActivePort file does not exist:
13:38:41.079 INFO [LoggingOptions.configureLogEncoding] - Using the system default encoding
13:38:41.086 INFO [OpenTelemetryTracer.createTracer] - Using OpenTelemetry for tracing
13:38:41.942 INFO [NodeOptions.getSessionFactories] - Detected 8 available processors
13:38:41.970 INFO [NodeOptions.discoverDrivers] - Discovered 3 driver(s)
13:38:41.997 INFO [NodeOptions.report] - Adding Edge for {"browserName": "MicrosoftEdge"} 8 times
13:38:41.999 INFO [NodeOptions.report] - Adding Chrome for {"browserName": "chrome"} 8 times
13:38:42.000 INFO [NodeOptions.report] - Adding Firefox for {"browserName": "firefox"} 8 times
13:38:42.039 INFO [Node.<init>] - Binding additional locator mechanisms: id, relative, name
13:38:42.067 INFO [LocalDistributor.add] - Added node fb3c75f0-847d-475d-88b0-dea6893c09c2 at http://172.19.0.7:4444. Health check every 120s
13:38:42.068 INFO [GridModel.setAvailability] - Switching node fb3c75f0-847d-475d-88b0-dea6893c09c2 (uri: http://172.19.0.7:4444) from DOWN to UP
13:38:42.251 INFO [Standalone.execute] - Started Selenium Standalone 4.0.0 (revision 3a21814679): http://172.19.0.7:4444
Starting MSEdgeDriver 95.0.1020.30 (09f7018e2a65a55dea3a0a261efca40ae03471ed) on port 36979
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping MSEdgeDriver safe.
MSEdgeDriver was started successfully.
[1634828868.563][SEVERE]: bind() failed: Cannot assign requested address (99)
15:07:48.749 WARN [SeleniumSpanExporter$1.lambda$export$0] - {"traceId": "49c55d39b0c26898585047f89ad32f33","eventTime": 1634828868685689900,"eventName": "exception","attributes": {"driver.url": "http:\u002f\u002flocalhost:36979","exception.message": "Error while creating session with the driver service. Stopping driver service: Could not start a new session. Response code 500. Message: unknown error: MSEdge failed to start: exited abnormally.\n (unknown error: DevToolsActivePort file doesn't exist)\n (The process started from msedge location \u002fusr\u002fbin\u002fmicrosoft-edge is no longer running, so MSEdgeDriver is assuming that MSEdge has crashed.)\nBuild info: version: '4.0.0', revision: '3a21814679'\nSystem info: host: 'dee4c77efe99', ip: '172.19.0.7', os.name: 'Linux', os.arch: 'amd64', os.version: '5.10.25-linuxkit', java.version: '11.0.11'\nDriver info: driver.version: unknown","exception.stacktrace": "org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Response code 500. Message: unknown error: MSEdge failed to start: exited abnormally.\n (unknown error: DevToolsActivePort file doesn't exist)\n (The process started from msedge location \u002fusr\u002fbin\u002fmicrosoft-edge is no longer running, so MSEdgeDriver is assuming that MSEdge has crashed.)\nBuild info: version: '4.0.0', revision: '3a21814679'\nSystem info: host: 'dee4c77efe99', ip: '172.19.0.7', os.name: 'Linux', os.arch: 'amd64', os.version: '5.10.25-linuxkit', java.version: '11.0.11'\nDriver info: driver.version: unknown\n\tat org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:126)\n\tat org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:84)\n\tat org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:62)\n\tat org.openqa.selenium.grid.node.config.DriverServiceSessionFactory.apply(DriverServiceSessionFactory.java:131)\n\tat org.openqa.selenium.grid.node.config.DriverServiceSessionFactory.apply(DriverServiceSessionFactory.java:65)\n\tat org.openqa.selenium.grid.node.local.SessionSlot.apply(SessionSlot.java:143)\n\tat org.openqa.selenium.grid.node.local.LocalNode.newSession(LocalNode.java:315)\n\tat org.openqa.selenium.grid.distributor.local.LocalDistributor.startSession(LocalDistributor.java:513)\n\tat org.openqa.selenium.grid.distributor.local.LocalDistributor.newSession(LocalDistributor.java:440)\n\tat org.openqa.selenium.grid.distributor.local.LocalDistributor$NewSessionRunnable.handleNewSessionRequest(LocalDistributor.java:648)\n\tat org.openqa.selenium.grid.distributor.local.LocalDistributor$NewSessionRunnable.lambda$run$1(LocalDistributor.java:612)\n\tat java.base\u002fjava.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)\n\tat java.base\u002fjava.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)\n\tat java.base\u002fjava.lang.Thread.run(Thread.java:829)\n","exception.type": "org.openqa.selenium.SessionNotCreatedException","logger": "org.openqa.selenium.grid.node.config.DriverServiceSessionFactory","session.capabilities": "{\"browserName\": \"MicrosoftEdge\"}\n"}}```
is there any way to make this work ?
Please make sure you have
127.0.0.1 localhost
in your /etc/hosts file.
To check it, you should go to the terminal and run
sudo vi /etc/hosts
type your user password and paste
127.0.0.1 localhost
to an empty row.
Additionally, please make sure you have ChromeDriver -or the driver of the browser you intend to use- is installed and your program knows the path of ChromeDriver.
You can follow the steps explained here https://www.browserstack.com/guide/run-selenium-tests-using-selenium-chromedriver.
For DevToolsActivePort error try another workaround: add --remote-debugging-port=
I tried a different version of Selenium server with Edge, including version 4, till version 3.5; it is working fine, and above, it gives different errors. I can see that Selenium 4 is in alpha release at the Maven repository, and all other versions were released in October 2021. I would recommend that you use an earlier version for some time. You can refer to this article for the configuration of Edge with Behat Mink Selenium 2.

How do I configure REST module in Codeception to use browserstack?

I am writing acceptance codeception tests on a web application. It will require me to check headers, specifically response codes. I have found that the codeception REST module can be used, but it appears to require phpbrowser. I am required though to use browserstack. How would the configuration look using browserstack as aposed to phpbrowser.
My acceptance.suite.yml is currently set up like:
chrome-dev:
modules:
enabled:
- WebDriver
- \Helper\
config:
WebDriver:
url: 'https://XXXXXXXXXXXXXXXXXX.com'
host: 'XXXXXXXX#XXXXXXXX.com:XXXXXXXXXX.browserstack.com'
port: 80
browser: 'chrome'
window_size: maximize
capabilities:
'os': 'Windows'
'os_version': '10'
'browser_version': '57'
'acceptSslCerts': true
'resolution': '1600x1200'
'browserstack.chrome.enablePopups': true
'browserstack.chrome.allowAllCookies': true
My question here is how would I insert the REST module without using phpbrowser? It appears that it may be required, but does anybody know otherwise?
It is impossible - WebDriver and REST modules are incompatible.

How to made to work Codeception + facebook webdriver agent?

okay, i'm setup appium 1.6.3 server on my mac, webdriver agent inspector works great on real device. now i have this config in codeception yml file:
actor: AcceptanceTester
modules:
enabled:
- \Helper\Acceptance
- \Appium\AppiumDriver:
host: 0.0.0.0
port: 4723
dummyRemote: false
resetAfterSuite: true
resetAfterCest: false
resetAfterTest: false
resetAfterStep: false
capabilities:
app : '/Users/kirill/Documents/iCanDeliver/Deliver.app'
platformName : 'ios'
platformVersion : '10.3'
deviceName : 'iPhone (Kirill)'
automationName : 'XCUITest'
udid: c57bcfcc08ee2485d02f30298dc98bef808a39a5
when I concept run any script appium server unlock the real device, deploy app, deploy webdriveragent, connect to webdriveragent, starting app OK,
but how to writing cases? maybe I made something wrong, there is no any info about codeception-webdriveragent.
Thanks!

Codeception + Selenium server- browser (chrome) pops up, but web page is always white

Using the latest Codeception.
Tried selenium server 2.40.0 and 2.42.2
Snippit of Config:
enabled:
- WebDriver
WebDriver:
url: 'foo'
browser: chrome
I have chrome web driver in my path.
From cmd line, I kick off the selenium server
java -jar C:\...\vendor\selenium\selenium-server-standalone-2.42.2.jar
From cmd line2,
run acceptance fooCept.php
Chrome opens, but the page is always blank. If I was only running one step, I remember not being able to see anything on the page because it was too quick. But with my latest go around with Codeception, I cannot get to see the web page when I over 30 steps.
Your config syntax is not correct. Try this in acceptance.suite.yml:
modules:
enabled:
- WebDriver
config:
WebDriver:
url: 'http://your.site.dev'
browser: 'chrome'
PHPBrowser was also enabled in the acceptance.suite.yml. Once I removed this, it worked.

Webception / webdriver / ftp

I use Codeception with webdriver and use command line to start tests. I try to use webception to show it on a web-application for my colleagues so I deployed webception on my FTP but i have problems with piloting selenium. I didnt succeed to run the test from my ftp with webcept.
[WebDriverCurlException]
Curl error thrown for http POST to http://127.0.0.1:4444/wd/hub/session with params: {"desiredCapabilities":{"unexpectedAlertBehaviour":"accept","browserName":"firefox"}}
couldn't connect to host
Here is my acceptance.suit.yml :
class_name: WebGuy
modules:
enabled:
#- PhpBrowser
- WebHelper
- REST
- WebDriver
config:
REST:
url: 'http://theAddress/'
timeout: 90
PhpBrowser:
url: 'http://theAddress/'
curl:
CURLOPT_RETURNTRANSFER: true
CURLOPT_FOLLOWLOCATION: true
WebDriver:
url: 'http://theAddress/'
browser: firefox
capabilities:
unexpectedAlertBehaviour: 'accept'
Any suggestions will be welcome. thank you
Try to run Selenium manually. Download Selenium Server here Selenium Downloads , then in the command line, navigate to the folder where the file has been downloaded and type:
java -jar selenium-server-standalone-W.XY.Z.jar
Now, Selenium should be running on the 4444 port. After that, try to run your test again.

Categories