Youtube page(WebView) automation on android Chrome browser - google-chrome

Able to successfully run opening of Youtube page(WebView) from android chrome browser in Appium 1.0.0.3.
Guys I got struck here. Please help me to achieve my objectives.
- I can't able to identify elements inside WebView using "uiautomatorviewer.bat"
- I can't able to switch to WebView through following code
- driver.switch_to.context('WEBVIEW')
one more I tried
- driver.switch_to.context(webview)
My objective:
Scenario 1:
Open Youtube page on android Chrome browser.
Select any video for playback.
Tap on pause and play.
Tap on Full screen button.
Scenario 2:
Open URL: "http://m.youtube.com/watch?v=7-7knsP2n5w" on android Chrome browser.
Tap on play button.
Sample code:
from appium import webdriver
desired_caps = {}
desired_caps['automationName'] = 'Appium'
desired_caps['platformName'] = 'Android'
desired_caps['platformVersion'] = '4.4'
desired_caps['deviceName'] = 'Nexus 7'
desired_caps['browserName'] = 'Chrome'
driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)
driver.get('http://m.youtube.com')
driver.switch_to.context('WEBVIEW') # Unable to switch to webview. Getting following error.
Python interpretor error:
Traceback (most recent call last):
File "C:\Python27\lib\bdb.py", line 400, in run
exec cmd in globals, locals
File "C:\Data\VVO\Automation\ROBOT_FRAMEWORK\AndroidTest\Appium\tmp_browser.py", line 2, in <module>
from appium import webdriver
File "build\bdist.win32\egg\appium\webdriver\switch_to.py", line 31, in context
self._driver.execute(MobileCommand.SWITCH_TO_CONTEXT, {'name': context_name})
File "C:\Python27\lib\site-packages\selenium-2.42.0-py2.7.egg\selenium\webdriver\remote\webdriver.py", line 172, in execute
self.error_handler.check_response(response)
File "build\bdist.win32\egg\appium\webdriver\errorhandler.py", line 29, in check_response
raise wde
WebDriverException: Message: 'unknown command: session/d6c14715e9f6ca685030f9f56a2b698e/context'
Appium server logs:
POST /wd/hub/session/74354d82912ad3db704d67eeb04a295b/url 200 18052ms - 85b
debug: Appium request initiated at /wd/hub/session/74354d82912ad3db704d67eeb04a295b/context
debug: Request received with params: {"sessionId":"74354d82912ad3db704d67eeb04a295b","name":"WEBVIEW"}
debug: Proxying command to 127.0.0.1:9515
info: Making http request with opts: {"url":"http://127.0.0.1:9515/wd/hub/session/74354d82912ad3db704d67eeb04a295b/
context","method":"POST","json":{"sessionId":"74354d82912ad3db704d67eeb04a295b","name":"WEBVIEW"}}
debug: Proxied response received with status 404: "unknown command: session/74354d82912ad3db704d67eeb04a295b/context"
POST /wd/hub/session/74354d82912ad3db704d67eeb04a295b/context 404 8ms - 65b

When you initialize your webdriver, the url should be set to http://0.0.0.0:9515/wd/hub/
You're having issues switching contexts because Appium isn't talking to the app successfully.
Try print driver.page_source and when that works (and prints out the page xml), the rest of everything (switching context, etc) should work, too.

Related

ValueError: Unknown URI - must be a path to an IPC socket, a websocket beginning with 'ws' or a URL beginning with 'http'

I am using Brownie and added a Ganache local network using the following command:
brownie networks add Development ganache-local host=HTTP://127.0.0.1:7545 cmd=ganache-cli
After compiling, I try to deploy the smart contracts with brownie run token.py --network ganache-local Then, I get the following error:
TokenProject is the active project.
File "brownie/_cli/__main__.py", line 64, in main
importlib.import_module(f"brownie._cli.{cmd}").main()
File "brownie/_cli/run.py", line 45, in main
network.connect(CONFIG.argv["network"])
File "brownie/network/main.py", line 40, in connect
web3.connect(host, active.get("timeout", 30))
File "brownie/network/web3.py", line 68, in connect
raise ValueError(
ValueError: Unknown URI - must be a path to an IPC socket, a websocket beginning with 'ws' or a URL beginning with 'http'
I did some digging and found this in the source code:
if self.provider is None:
if uri.startswith("ws"):
self.provider = WebsocketProvider(uri, {"close_timeout": timeout})
elif uri.startswith("http"):
self.provider = HTTPProvider(uri, {"timeout": timeout})
else:
raise ValueError(
"Unknown URI - must be a path to an IPC socket, a websocket "
"beginning with 'ws' or a URL beginning with 'http'"
)
Does this mean I have to set a provider (like Alchemy) for my local network? Does that even make sense?
After 4 days of struggling, passing the network_id=5777 argument solved my problem. Apparently, brownie cannot recognize the local network created in the Ganache app without this argument.

Flutter App to Web through Github pages blank screen

I have a page generated by Flutter-Web shops and it is a blank page. And I have an error in the console. This happened after uploading the build web of Flutter into GitHub Pages.
Uncaught (in promise) TypeError: Failed to register a ServiceWorker for scope ('https://adamtechnologynl.github.io/') with script ('https://adamtechnologynl.github.io
/flutter_service_worker.js?v=2470069411'): A bad HTTP response code (404) was received when fetching the script.
manifest.json:1 Failed to load resource: the server responded with a status of 404 ()
manifest.json:1 Manifest: Line: 1, column: 1, Syntax error.
manifest.json:1 Failed to load resource: the server responded with a status of 404 ()
(index):88 Failed to load app from service worker. Falling back to plain <script> tag.
(anonymous) # (index):88
(index):47 GET https://adamtechnologynl.github.io/main.dart.js net::ERR_ABORTED 404
loadMainDartJs # (index):47
(anonymous) # (index):91
I found the solution. This happens when you have put it another directory instead of the root of the GitHub.
So my code is in "https://username.github.io/demo/book-king/belasting-web-v1/" so that last part we should append everything after "https://username.github.io/" also in the index.html. You can solve it by modifying the line (number 17 by me):
Change:
<base href="/">
into:
<base href="/demo/book-king/belasting-web-v1/">
And then you are done.
This solution works. But for me, line no 17 was not <base href="/">.
It was like this <base href="$FLUTTER_BASE_HREF">. Given that FLUTTER_BASE_HREF is a variable, it can be modified.
How?: Provide --base-href argument to flutter build like below
HostingURL : https://<github_user_name>.github.io/project_aj/demo/gh-pages/
Apart from the https://<github_user_name>.github.io should go as the value for --base-href
flutter build web --base-href=/project_aj/demo/gh-pages/

Heroku app: Error during WebSocket handshake: Unexpected response code: 200

I followed a tutorial on how to make a multiplayer tetris game, here is the repo:
https://github.com/Leftier/tetris
It worked just fine on localhost so I tried to deploy it in heroku (https://tetrixtest.herokuapp.com/ --ASD to move Q/E to rotate) but I get the following error:
WebSocket connection to 'wss://tetrixtest.herokuapp.com/' failed: Error during WebSocket handshake: Unexpected response code: 200
while trying to create the webSocket in this line (connection-manager.js line 14):
this.conn = new WebSocket(`wss://${window.location.hostname}:${window.location.port}`)
I don't know much about webSockets,
at first I thought that heroku was not able to handle websockets but that wasn't the case so I tried using the link directly as an argument instead of reading it from the browser but still the same issue.
I would like some clues/hints about why does this happens, I searched in google and github, but I only found issues related to socket.io
For me the solution was to turn on "Session affinity" by running this command heroku features:enable http-session-affinity
More info at https://devcenter.heroku.com/articles/session-affinity
Session affinity, sometimes referred to as sticky sessions, is a
platform feature that associates all HTTP requests coming from an
end-user with a single application instance (web dyno).

Chrome Debugger Api Attach Extension Error

Task: Debug other extensions using chrome debugger api.
Expected Output: http request logs made by other installed extensions.
Method: Running chrome webdriver with selenium in python setting flag chromeopts.add_argument('--silent-debugger-extension-api' ). Inside my extension, On event chrome.management.onInstalled using following code
chrome.debugger.attach({ extensionId: info.id }, version, onAttach.bind(null, info.id));
chrome.debugger.sendCommand({ extensionId: info.id }, "Network.enable");
chrome.debugger.onEvent.addListener(onEvent);
Error: Cannot access a chrome-extension:// URL of different extension
To debug the background page of another extension, you need to set two flags:
--silent-debugger-extension-api
To allow debugging of background pages.
--extensions-on-chrome-urls
To allow debugging of other extensions.

Unable to Launch Chrome Browser in Selenium

I am launching chrome browser using
selenium = new DefaultSelenium("localhost", 4444, "*googlechrome",
"https://example.com/");
But i get a popup with following message and it freezes:
An administrator has installed Google Chrome on this system, and it is available for all users. The system-level Google Chrome will replace your user-level installation now.
Console Log till point of freeze:
Server started
16:06:37.792 INFO - Command request: getNewBrowserSession[*googlechrome, https://example.com/, ] on session null
16:06:37.796 INFO - creating new remote session
16:06:38.081 INFO - Allocated session beb925cd0418412dbe6319fedfb28614 for https://example.com/, launching...
16:06:38.082 INFO - Launching Google Chrome...
Any suggestions?
Try giving location of your chrome exe too along with browser name like this :
selenium=new DefaultSelenium("localhost", 4444, "*googlechrome C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe", "https://example.com");