Protractor - Setting DPI with chromeOptions - angularjs

I'm writing functional tests with protractor and am trying to emulate a mobile device using chrome on a desktop. I've successfully set the user agent with:
config.capabilities = {
browserName: 'chrome',
chromeOptions: {
args: ['--user-agent="Mozilla/5.0 (iPad; CPU OS 7_0 like Mac OS X) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/7.0 Mobile/11A465 Safari/9537.53"']
}
};
Now, I'd like to change the DPI to reflect mobile devices (usually with a DPI of 2). I've explored other args and came across --ash-host-window-bounds (http://peter.sh/experiments/chromium-command-line-switches/#ash-host-window-bounds). I've tried:
chromeOptions: { args: ['--ash-host-window-bounds="1024x768*2"'] }
It seems like the argument doesn't work with protractor, as it does not affect the window dimensions when removing the DPI argument.
How could I set the DPI? Or, how could I enable Chrome Mobile Emulation via chromeOptions?

capabilities: {
"browserName": 'chrome',
chromeOptions: {
args: ['--user-agent="Mozilla/5.0 (iPhone; CPU iPhone OS 8_0 like Mac OS X) AppleWebKit/600.1.3 (KHTML, like Gecko) Version/8.0 Mobile/12A4345d Safari/600.1.4"'],
mobileEmulation: {
"device": 'Apple iPhone 6 Plus',
"deviceMetrics": {
"width": 414,
"height": 736,
"pixelRatio": 3.0
}
}
}
},

Related

WebRTC : Screenshare video quality constraints not working on latest version of MAC Safari in reactJS

I have been trying to set screen share video quality using height constraint but on the latest version of MAC Safari, it's not working.
MAC OS Version: 13.1
Safari Version: 16.2
Here is code
let constraints = {
aspectRatio: 1.777,
frameRate: 15,
height: 480
}
navigator.mediaDevices
.getDisplayMedia({video :constraints})
.then((stream) => {
// success
})
.catch(e => {
// error
});
I have tried this constraint but not working
var constraints = {
mandatory: {
maxHeight: 480,
aspectRatio: 1.777,
frameRate: 15,
},
optional: []
}
I had the same issue with 16.2.1 and apparently they have improved screen capture in 16.1 to support sharing Window or Screen when calling getDisplayMedia and somehow it breaks height and width constraints, all you need to do is removed height in your constraints then it should works.
let constraints = {
aspectRatio: 1.777,
frameRate: 15
}
https://webkit.org/blog/13399/webkit-features-in-safari-16-1/
After checking the webkit update, found the issue has come up due to a change in the WebKit engine.
Here is the link
The issue will fix in Safari 16.4 version.
Here is the release node link
2023/01/10 Update
After hours of investigation for nothing but just people asking for helps and opened WebKit bug tickets without answers. I found Google Meet screen sharing works nicely on all Safari 16.x, so I hijacked the native API navigator.mediaDevices.getDisplayMedia to see what are the constraints Google Meet is using and this works nicely for me on 16.1 16.2, 16.4 (Safari Technology Preview), 15,x and 14.x
navigator.mediaDevices.getDisplayMedia({ height: { max: 1205 }, width: { max: 2880 }, frameRate: 5 });

Spam from multiple user agents, same IP

I have a lot of spam posts in a forum that I moderate that I can't quite figure out.
(1) The spammer seems to be getting through Captcha
(2) I have logged the same IP (a Charter/Spectrum address -- so I can't block the ASN) for the following User Agents:
[
{
"userAgent": "Nokia7250/1.0 (3.14) Profile/MIDP-1.0 Configuration/CLDC-1.0"
},
{
"userAgent": "Mozilla/5.0 (PlayBook; U; RIM Tablet OS 2.1.0; en-US) AppleWebKit/536.2+ (KHTML like Gecko) Version/7.2.1.0 Safari/536.2+"
},
{
"userAgent": "P3P Validator"
},
{
"userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:40.0) Gecko/20100101 Firefox/40.0"
},
{
"userAgent": "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:55.0) Gecko/20100101 Firefox/55.0"
},
{
"userAgent": "Bloglines/3.1 (http://www.bloglines.com)"
},
{
"userAgent": "SonyEricssonK810i/R1KG Browser/NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1"
},
{
"userAgent": "SonyEricssonT610/R201 Profile/MIDP-1.0 Configuration/CLDC-1.0"
},
{
"userAgent": "Mozilla/5.0 (Linux; U; Android 1.5; de-de; Galaxy Build/CUPCAKE) AppleWebKit/528.5 (KHTML, like Gecko) Version/3.1.2 Mobile Safari/525.20.1"
},
{
"userAgent": "Baiduspider ( http://www.baidu.com/search/spider.htm)"
},
{
"userAgent": "Mozilla/5.0 (Windows NT 6.2; ARM; Trident/7.0; Touch; rv:11.0; WPDesktop; NOKIA; Lumia 920) like Geckoo"
},
{
"userAgent": "Mozilla/5.0 (Linux; U; Android 1.5; de-de; Galaxy Build/CUPCAKE) AppleWebKit/528.5 (KHTML, like Gecko) Version/3.1.2 Mobile Safari/525.20.1"
},
{
"userAgent": "SEC-SGHX210/1.0 UP.Link/6.3.1.13.0"
},
{
"userAgent": "SEC-SGHX210/1.0 UP.Link/6.3.1.13.0"
},
{
"userAgent": "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US) AppleWebKit/534.14 (KHTML, like Gecko) Chrome/9.0.601.0 Safari/534.14"
},
{
"userAgent": "Mozilla/5.0 (Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko"
},
{
"userAgent": "Gaisbot/3.0 (robot#gais.cs.ccu.edu.tw; http://gais.cs.ccu.edu.tw/robot.php)"
},
{
"userAgent": "Mozilla/5.0 (Maemo; Linux armv7l; rv:10.0.1) Gecko/20100101 Firefox/10.0.1 Fennec/10.0.1"
},
{
"userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:47.0) Gecko/20100101 Firefox/47.0"
},
{
"userAgent": "Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_3 like Mac OS X; de-de) AppleWebKit/533.17.9 (KHTML, like Gecko) Mobile/8F190"
}
]
]
This is just an example, but the pattern is common. Multiple UA's from the same IP over a period of time, and the IP is almost always tied to a common consumer ISP. Any thoughts on this?
Let me know if you can think of something else I could log that would also be useful. Thanks!
But then why wouldn't the spammer just use something super common like the current Safari iPhone UA?
Spammers usually use specific tools like Xrumer, which allows automatic change useragent, email registration, solve Captcha etc.
Anti-spam efficiency is based on resource consumption. A moderator must waste a few seconds to remove spam, but a spammer must waste a few minutes to made his durty things.
Therefore, it is necessary to deprive the spammer of the opportunity to automate his process.
Use a serious captcha - reCaptcha, hCaptcha, etc.
Close the ability to post without registration.
Prohibit the use of automatic mail services such as mailforspam.com for registration.
If we are dealing with a bot and not a person, invisible fields are added to the registration form, which the person will not fill, but the bot will see these in the HTML code and fill in.
Replacing the Submit button with the corresponding image. <input type = 'submit' value='Post'> remains in the HTML code, but the form is not submitted by it. Submitting the form is done by clicking on the picture, which the robot does not see, but the person sees.
There are many tricks, but it all depends on the capabilities of the forum engine.
To begin with, it would be nice to determine whether a person is spamming or a robot.

How to automate already installed ios Apps using Appium

How to automate already installed ios Apps using Appium. I want to automate like whatsap ebay and other installed apps in my iphone using appium.
You should be able to automate the app if you know the bundleId of the application. For WhatsApp the bundleId is net.whatsapp.WhatsApp
If your Appium set up is correct and have python installed then, start an Appium Server and Run the sample python code. You can attach the session to the Appium inspector to inspect the elements.
from appium import webdriver
desired_caps = {}
desired_caps['platformName'] = 'iOS'
desired_caps['platformVersion'] = '12.4.6'
desired_caps['name'] = 'Sample Test'
desired_caps['deviceName'] = 'iPhone 6'
desired_caps['udid'] = 'add_your_device_udid_here'
desired_caps["bundleId"] = "net.whatsapp.WhatsApp"
desired_caps["noReset"] = True
desired_caps["newCommandTimeout"] = 50000
driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)
You need to add bundle ID capability with existing capabilities.
DesiredCapabilities caps = new DesiredCapabilities();
caps.setCapability(MobileCapabilityType.UDID, "udid");
caps.setCapability(MobileCapabilityType.PLATFORM_VERSION, "12.4");
caps.setCapability(MobileCapabilityType.DEVICE_NAME, deviceName);
caps.setCapability(MobileCapabilityType.PLATFORM_NAME, "iOS");
caps.setCapability("unicodeKeyboard", true);
caps.setCapability(MobileCapabilityType.AUTOMATION_NAME, "XCUITest");
caps.setCapability(MobileCapabilityType.NO_RESET, true);
caps.setCapability("bundleId", "com.company.appname");
caps.setCapability("usePrebuiltWDA", true);
IOSDriver<WebElement> driver = new IOSDriver<WebElement>(new URL("http://127.0.0.1:4444/wd/hub"), caps)
I have added UDID capability which is used for real device.
this work for me
{
"automationName": "XCUITest",
"platformName": "iOS",
"deviceName": "iPhone",
"udid": "...",
"xcodeOrgId": "...",
"platformVersion": "xx.y",
"updatedWDABundleId": "com.facebook.WebDriverAgentRunner"
}

AppEngine Standard Python 3.7 does not provide error message with 500 response

I'm creating an AppEngine application with python3.7 standard environment. The application works ok locally, but when uploaded it throws a 500 error in the browser it shows:
"Internal Server Error
The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application."
Debugging is not enabled for python3.7 (it tells me that when viewing the debugger). And the log entries don't have the hint of an error message within them against the 500 response.
How do I proceed to debug and understand what's happening to the application?
I should note that I'm attempting to use a Selenium webdriver to run headless chrome and I'm not 100% sure this is compatible with this environment, I was just trying to give it a go.
Adding in log as suggested
https://console.cloud.google.com/logs/viewer?project={project-id}&resource=gae_app%2Fmodule_id%2Fdefault%2Fversion_id%2F20180916t193009&minLogLevel=0&expandAll=false&timestamp=2018-09-17T18%3A18%3A21.295000000Z&customFacets&limitCustomFacetWidth=true&interval=PT1H&scrollTimestamp=2018-09-17T18%3A16%3A59.235127000Z&advancedFilter=resource.type%3D%22gae_app%22%0Aresource.labels.zone%3D%22us-west2-3%22%0Aresource.labels.project_id%3D%22{project-id}%22%0Aresource.labels.version_id%3D%2220180916t193009%22%0Aresource.labels.module_id%3D%22default%22%0Atimestamp%3D%222018-09-17T18%3A16%3A57.883459000Z%22%0AinsertId%3D%225b9fef9e0005ebc57890705d%22&dateRangeUnbound=both
{
httpRequest: {
status: 500
}
insertId: "5b9fef9e0005ebc57890705d"
labels: {
clone_id: "00c61b117c38b726d0ba73ce89f222fe10b9b189fae907de84b949ab7a3b88ec4bdc4484"
}
logName: "projects/{project-id}/logs/appengine.googleapis.com%2Frequest_log"
operation: {
first: true
id: "5b9fef9900ff0d7b03fbff00a7c100016d7e7370656e642d6d6f6e69746f720001323031383039313674313933303039000100"
last: true
producer: "appengine.googleapis.com/request_id"
}
protoPayload: {
#type: "type.googleapis.com/google.appengine.logging.v1.RequestLog"
appEngineRelease: "1.9.64"
appId: "m~{project-id}"
cost: 4.7272999999999996e-8
endTime: "2018-09-17T18:17:02.387819Z"
finished: true
first: true
host: "{project-id}.appspot.com"
httpVersion: "HTTP/1.1"
instanceId: "00c61b117c38b726d0ba73ce89f222fe10b9b189fae907de84b949ab7a3b88ec4bdc4484"
instanceIndex: -1
ip: "80.195.185.178"
latency: "4.504360s"
line: [
0: {
logMessage: "This request caused a new process to be started for your application, and thus caused your application code to be loaded for the first time. This request may thus take longer and use more CPU than a typical request for your application."
severity: "INFO"
time: "2018-09-17T18:17:02.387649Z"
}
]
megaCycles: "6127"
method: "GET"
requestId: "5b9fef9900ff0d7b03fbff00a7c100016d7e7370656e642d6d6f6e69746f720001323031383039313674313933303039000100"
resource: "/"
responseSize: "423"
startTime: "2018-09-17T18:16:57.883459Z"
status: 500
traceId: "37cee4aaaa0b14fbaa6d57b7842527dc"
traceSampled: true
urlMapEntry: "auto"
userAgent: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36"
versionId: "20180916t193009"
wasLoadingRequest: true
}
receiveTimestamp: "2018-09-17T18:17:02.563417716Z"
resource: {
labels: {
module_id: "default"
project_id: "{project-id}"
version_id: "20180916t193009"
zone: "us-west2-3"
}
type: "gae_app"
}
severity: "INFO"
timestamp: "2018-09-17T18:16:57.883459Z"
trace: "projects/{project-id}/traces/37cee4aaaa0b14fbaa6d57b7842527dc"
traceSampled: true
}
In order to debug this further I inserted a try/catch block like so:
try:
{application code}
except Exception as e:
return str(e)
This lands the top level error message in the browser when the application fails.

Nightwatch selenium client.url never gets done

I'm having an issue with my tests I run with Selenium-webdriver, Chromedriver and nightwatch.js. I run two terminal windows, one with selenium and one with the test. I'm running this on a macbook air with macOS Sierra.
My test look like:
module.exports = {
'Demo test' : function (browser) {
browser.url();
browser.pause(1000);
browser.maximizeWindow();
browser.resizeWindow(300, 300);
browser.maximizeWindow();
browser.pause(2000);
browser.url('http://www.google.se').resizeWindow(500, 500);
browser.end();
}
};
This gives the following output in the terminal when I run java -jar selenium-server-standalone-3.0.0.jar and then run the test in another terminal window:
test is run like
node nightwatch.js tests/demo.js
And it gives this output in the selenium terminal window.
09:11:21.617 INFO - Executing: [get current url])
09:11:21.663 INFO - Done: [get current url]
09:11:22.680 INFO - Executing: [maximise window])
09:11:22.941 INFO - Done: [maximise window]
09:11:22.950 INFO - Executing: [set window size])
09:11:23.073 INFO - Done: [set window size]
09:11:23.080 INFO - Executing: [maximise window])
09:11:23.565 INFO - Done: [maximise window]
09:11:25.577 INFO - Executing: [get: http://www.google.se])
After this nothing more happens. For some reason I don't get a done callback from client.url() when I have a real webpage and just not a empty window.
Does anyone have an idea what the problem is?
You have mentioned that you are using selenium 3.0.0. You have not mentioned which browser you are using and what version of its driver you are using.
I tried this code on two settings. Both settings had nightwatch 0.9.8, chromedriver 2.25, Chrome Browser v54. OS was always OSX Sierra 10.12.1. One setting had selenium 2X while the other had selenium 3.0.1
In both settings, your test code executed successfully. So this way it is difficult to help you find a solution to this problem
Here is the nightwatch config
{
"src_folders" : ["tests"],
"output_folders" : "reports",
"selenium" : {
"start_process" : true,
"server_path" : "tools/selenium3.jar",
"log_path" : "",
"host" : "127.0.0.1",
"port" : 4444,
"cli_args" : {
"webdriver.chrome.driver" : "tools/chromedriver",
"webdriver.ie.driver" : ""
}
},
"test_settings" : {
"default" : {
"launch_url" : "http://www.google.com",
"selenium_port" : 4444,
"selenium_host" : "localhost",
"silent": true,
"screenshots" : {
"enabled" : false,
"path" : ""
},
"desiredCapabilities": {
"browserName": "chrome",
"javascriptEnabled": true,
"acceptSslCerts": true
}
}
}
}

Resources