Auto refresh chrome page on Android (C++) - android

I'm trying to create an app that will refresh a chrome page every day without user intervention.
It's the first time I create something on Android and I have no clue on what to do. I tried searching on google but I only find answers about Javascript or incomplete answers. I also tried to simulate touchscreen input, but I can't make it work.
I use Visual Studio 2022 to write my code and I have, for now, only the base of the app.
to summarize, I want the app to :
be a background app/process
refresh a chrome page everyday at around 5AM
work without any help from the user
How can I do that ?
(If needed I can still switch to a javascript code)
ty

Related

Switching to an iframe on android native and web app using appium via ROBOT framework

Hi I have been searching a lot on the internet to find how i am supposed to switch from web or native context view to an iframe. I am trying to automate a user logging into an app and the third piece of identification is generating a OTP. This happens to be inside an iframe and i have tried quite a few things to interact with it. Firstly I cannot find any good documentation on how to achieve this through keywords (Appium) using robot, and i do not have a lot of programming experience to write it in python then call it but i have tried.
First thing i tried was using the keyword 'switch to context' and 'get contexts' which i am already using to switch between native and webview already:
List Contexts
${contexts}= Get Contexts
${native}= Get From List ${contexts} 0
${webview}= Get From List ${contexts} 1 #-1
${chromeviewiframe} get from list ${contexts} -1 #1
Set Test Variable ${native}
Set Test Variable ${webview}
set test variable ${chromeviewiframe}
#Test Case code
sleep 60
list contexts
switch to context ${chromeviewiframe}
wait until element is visible xpath=//*[#id="btnSMS"] 30
click element xpath=//*[#id="btnSMS"]
However it never finds the iframe or button and therefore times out - I am not sure if 'get contexts' can be used to find iframes.
I have also tried to put the little bit of code appium supplied on their page into a python file in which i intended to call and hoped that would switch frames but didnt succeed at this attempt
#no idea what library's i am supposed to import and if the return makes sense?
class _frames():
def frame (self):
self.driver.switch_to.frame(3)
return self.driver.switch_to.frame(3)
My iframe xpath is (x'd out some characters) #iframe //*[#id="xxx2iframe"]
I have been having errors such as:
The phone is still activate and connection isnt lost but i think it just cant find the iframe context - I cant properly test the python file as the code isn't compelete and im not sure what i need to do to fix it to test that 'solution' out. I also wondered if i had another file calling selenium and call the switch frame keyword would it work for appium automation as they use the same drivers? I assume not?
Help to figure this out would be much appreciated, there isn't much point in me writing automation test cases if i cannot get it to automatically log in and get past this point.
Kind Regards, Jem
Ok so if anyone else searches for this question ive came up with an answer which is similar to the solution to this question: How to find XPath for button within iframe using python?
However it didn't relate and explain how it could be used in Robot framework so what i did was:
Clicked (ctrl+click) on appium keywords from my robot file which open the '_applicationmannagement.py' file which contains all the python methods which make up the keywords for appium Library
2.Inserted the following method in python:
def frame (self):
driver = self._current_application()
driver.switch_to.frame(driver.find_element_by_xpath( "//*[#id=\"xxx2iframe\"]"))
WebDriverWait(driver, 30).until(EC.element_to_be_clickable(("xpath","//*
[#id='btnSMS']"))).click()
Then in my robot file i simply just call the python method frame by writing the word 'frame' as part of my test case
This method switches to the iframe by using xpath and then it waits up until 30 seconds to find the button and once found it clicks it.
One thing to point out which was stopping this was the emulator might need to be restarted as at one point it would not load the iframe on the device.
I really hope this helps someone!
Please set your default browser as Chrome and then restart the device. The webviews will be automatically detected by Appium after that.

How do I trigger a button in an html page, from my android app?

I am working on a simple Home Automation project, using Raspberry Pi3. The basic idea is to have an Android app which can switch on/off an electric bulb. I have created a simple HTML web page which runs a python script to turn on/off the connected relay to the light bulb, whenever I press the corresponding buttons on the web page.
What i want to achieve is to have the buttons on the web page somehow toggled from buttons on a simple Android app.
Please understand that I am almost entirely new to app development and have no interests in further pursuing it. So I am looking for some workaround maybe, or a quick solution that helps me use my already functional web page, just from a simple android app. I would be able to implement the development part, hopefully, if I can get an idea of what exactly do I have to develop for achieving the above mentioned functionality.

create-react-app not working when added to android home screen

I got an app created with react material-ui, react-router v4 and using featherjs as backend. If I visit from the browser, the data loads and render but when I add it to my smartphone's home screen and view it. It doesn't load any data or render.
What's the problem? How can I debug this?
It's 4 months old, but i figured other people like me would benefit from an answer to the question. I found an article online : https://ayastreb.me/react-router-in-home-screen-pwa/
The idea is that you need to use hash based navigation for the router when your app starts from the homescreen as a standalone app (otherwise router doesn't fire up and your app is doing nothing). You can detect the case on lauch and switch to a hash based navigation - see the article.

Mobile Firefox addon development: window.BrowserApp.deck is null

I'm trying to write a simple little addon for Firefox Mobile, starting from this skeleton. Ultimately I'd like to be running a bit of code against every new page loaded, which seems to be best accomplished by adding a "DOMContentLoaded" listener to every new tab, which fires when that tab loads a new page. To that end I need to detect new tabs, which is apparently in turn done by adding a "TabOpen" listener to the BrowserApp's deck.
Problem: At startup (but not when installing into an already loaded session), window.BrowserApp.deck is null for the only window. The documentation, what little there is, doesn't seem to suggest this is possible.
To test this yourself, download the skeleton linked above and add
window.NativeWindow.toast.show(window.BrowserApp, "long");
below line 48 of bootstrap.js, then build, install on Mobile Firefox, and restart. You'll see a toast reporting BrowserApp's properties, including 'deck: null'. (I'm also currently hosting a copy of the extension you'll so obtain on my server, which is be much quicker to test: just point your Mobile Firefox browser to that link, install, and restart.)
What gives? Am I misreading something? Is there a better way of doing what I'm trying to do which won't run into this problem? Is there more extensive documentation somewhere?
Wait for the UIReady event.
window.addEventListener("UIReady", function(){your code}, false);

Android: How to use a Android Pad as a customer information Terminal

I want to us an Android-powered Pad as an information terminal for my customers.
The only thing it has to to is to show a HTML5 Webpage.
Therefore,
1. it should not be posiible to show another website (only the local one), should be no problem
it should be only possible to leave the app with a password (how?)
and all buttons should be disabled (that´s hard).
I found out how to set the target for the home button, but maybe there is an existing solution.
Thanks
Christian
I assume you understand the easiest way to do this is to develop an Android native application to show your webpage. This is done by using a WebView, but the support of HTML5 depends on the platform, so if you use any video or audio, you may need some hooks.
Trhough a WebView, you can filter which urls can be opened or not.
And well, I don't think there are many problems on exiting only when a password is entered.
Regarding to number 2, AFAIK, you can let your Activity ("window" of the application) to handle most of keys, but obviously you can't map the power key.
But I have to confess, when you develop an application, you always find some issues... so probably is not that easy as I wrote in these lines... Good luck!

Categories

Resources