Blackberry 10 WebView: Content doesn't get updated after URL changes - c++

I wrote a code that updates WebView URL of Blackberry main.qml after certain process gets executed. Qt/C++ code that updates WebView URL is given below
QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(this);
qml->setContextProperty("app",this);
AbstractPane *root = qml->createRootObject<AbstractPane>();
responseWebPage = root->findChild<WebView *>("responseWebPage");
responseWebPage->setUrl(QUrl(homePath + "/Appname/updatedhtml.html"));
WebView section of main.qml is
WebView {
id: responseWebPage
objectName: "responseWebPage"
accessibility.name: "responseWebPage"
url: "local:///assets/initialcontent.html"
onUrlChanged: {
console.debug("URL is changed. New URL is " + responseWebPage.url);
}
}
I am able to see updated URL name in logs printed by WebView console debug. I also verified that that updatedhtml.html file exists. (Checked through Target File System Navigator). Yet after the URL is set, I do not see content of updatedhtml.html being displayed either in device or simulator. Is there any step I am missing? Any help is greatly appreciated

Related

Google Sign In showing blank screen in iOS

I have implemented code as per the google SDK documentation line by line in my app, but still when I click on google sign in button app shifts to new view controller with webview with blank screen. Have tried multiple solution found here : GIDSignIn white screen on iOS 91. But no lucks with resolving the problem , have attached the screen shot for getting closer look about the screen.
Following are the pods that I'm using,
Running XCode 9.1, iOS 10.0 and later. Kindly request someone to help.
Update: View Hierarchy
Update: viewDidLoad's code:
GIDSignIn.sharedInstance().uiDelegate = self
if self.isChangePassword {
self.addSignInView()
}
else {
self.addSignUpView()
}
fileprivate func addSignInView() {
guard let signInEmailView: SignInEmailView = Bundle.main.loadNibNamed(NibNames.SignInEmailView.rawValue, owner: self, options: nil)?[0] as? SignInEmailView
else {
return
}
signInEmailView.delegate = self
gaManager.trackScreen(screenName: ScreenNames.SignIn.rawValue)
self.animateView(signInEmailView)
}
fileprivate func addSignInView() {
guard let signInEmailView: SignInEmailView = Bundle.main.loadNibNamed(NibNames.SignInEmailView.rawValue, owner: self, options: nil)?[0] as? SignInEmailView
else {
return
}
signInEmailView.delegate = self
gaManager.trackScreen(screenName: ScreenNames.SignIn.rawValue)
self.animateView(signInEmailView)
}
I have the same problem. I use the UIAlertView to confirm user really want to do authorization. It will show the blank screen. If I remove the UIAlertView and show the authorization view directly. It works fine.
The problem also show in the Dropbox authorization screen.
If you not use UIAlertView , please try to pass the top most controller
https://github.com/dropbox/dropbox-sdk-obj-c/issues/182
Hope this can do some help.
Finally after so many days found the problem. I was showing splash view from my appDelegate using refrence of UIWindow which was adding and removing an imgview as subview to the window. So it was somehow messing with the UINavigation's stack and my view controller was not getting any reference to the UINavigationController. After removing that code it's working just fine. Also came to the solution that, if I want to show splash screen, as I can't use UIWindow's reference, I have to add new VC and write my all navigation code there. #TedYu Thank you very much for the help. :)

Accept a Popup using Phantomjs with Selenium

I am using python 2.7, Selenium, and PhantomJs.
When I click the sign in button in my script it goes to a new page and a popup appears that I must accept.
Here is the code I am trying to use. I got it from here
How can I handle an alert with GhostDriver via Python?
sign_in.click()
js = 'window.alert = function(message) { lastAlert = message; }'
driver.execute_script("%s" % js)
driver.execute_script("return lastAlert")
Here is the error that I get:
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message:
{"errorMessage":"Can't find variable: lastAlert","request":{"hea
ders":{"Accept":"application/json","Accept-Encoding":"identity","Connection":"close","Content-Length":"95","Content-Type
":"application/json;charset=UTF-8","Host":"127.0.0.1:56712","User-Agent":"Python-urllib/2.7"},"httpVersion":"1.1","metho
d":"POST","post":"{\"sessionId\":
\"3832e2c0-4902-11e6-b766-0d7f487d0794\", \"args\": [], \"script\":
\"return lastAlert
\"}","url":"/execute","urlParsed":{"anchor":"","query":"","file":"execute","directory":"/","path":"/execute","relative":
"/execute","port":"","host":"","password":"","user":"","userInfo":"","authority":"","protocol":"","source":"/execute","q
ueryKey":{},"chunks":["execute"]},"urlOriginal":"/session/3832e2c0-4902-11e6-b766-0d7f487d0794/execute"}}
Screenshot: available via screen
I am not very experienced with javascript and a point in the right direction would be useful.
Here is the Behat step that I'm using:
/**
* This step overrides windows.confirm and basically accepts it before it is displayed.
*
* #When /^(?:|I )bypass the popup$/
*/
public function bypassPopup() {
$function = "
var realConfirm=window.confirm;
window.confirm=function(){
window.confirm=realConfirm;
return true;
};
";
$session = $this->getSession();
$session->executeScript($function);
}
You place it before you click on the button and when you click your popup will be accepted automatically.
In this case, only the first popup will be accepted.

Get webview document title when HTML is loaded

I have the following Qt webview:
QWebView *view = new QWebView();
view->load(QUrl("http://example.com"));
I want to get the title of document when load is finished, and use it to set the main window title.
From what I suppose view->loadFinished() returns true if page was loaded or not.
For setting the window title I use webView->setWindowTitle(newTitle). So, I need that newTitle variable that I want to be the document title.
How can I do this?
QWebView::loadFinished is a signal. You can subscribe to it to know when the page is loaded:
connect(view, SIGNAL(loadFinished(bool)), this, SLOT(onLoaded()));
To access HTML title you can use QWebView::title property.
void onLoaded()
{
window->setWindowTitle(view->title());
}
Rather then using loadFinished it may be more appropriate to use signal titleChanged(const QString& title) to apply a new title to the window:
connect(view, SIGNAL(titleChanged(QString)), this, SLOT(setWindowTitle(QString)));
EDIT:
Example:
QWebView* webView = new QWebView();
connect(webView, SIGNAL(titleChanged(QString)), webView, SLOT(setWindowTitle(QString)));
webView->load(QUrl("http://yahoo.com"));
webView->show();

Qt get DOM from page without updating GUI

I'm modifying the DOM Traversal example that comes with Qt. However, whenever I see a link, I want to "go" to that URL and also traverse its DOM, but I don't want to reload the GUI. Right now I'm still using the code from the example to get the homepage:
void Window::on_webView_loadFinished()
{
treeWidget->clear();
QWebFrame *frame = webView->page()->mainFrame();
QWebElement document = frame->documentElement();
examineChildElements(document, treeWidget->invisibleRootItem());
}
This works great. In examineChildElements(), when I encounter a specific link, I then call another function with the URL (I checked the URL string; it's correct):
void Window::parse_page(QString page_URL)
{
QWebView *innerPage = new QWebView();
innerPage->setUrl(page_URL);
QWebFrame *frameInner = innerPage->page()->mainFrame();
QWebElement documentBetrieb = frameInner->documentElement();
get_biz_info(documentBetrieb);
delete innerPage;
return;
}
But when I traverse this document (documentBetrieb), there is only an HTML tag. Is there a step I'm missing, or a way of putting the DOM from a URL directly into a QWebElement without using QWebView?
Are you sure setUrl() is loading the URL synchronously? I suppose you need listen to QWebView::loadFinished(bool ok) signal before accessing the DOM.

How to display a web page using QT/C++

I am trying to display a web page using the below code
QWebView *view = new QWebView();
view->load(QUrl("qrc://images//sample page.html/"));
view->show();
sample page.html is added to project resources/Images. The web page frame is loading, but I can't see any html data.
I tested with the below web url and it loaded the page
view->load(QUrl("http://www.google.com/"));
You will have to go through a few steps as follows:
1) Get the QWebPage object:
QWebPage *page = view->page();
2) Get the QWebFrame object:
QWebFrame *frame = page->currentFrame();
3) Call the toHtml member function on the current frame:
QString html = frame->toHtml();
Of course, you will need to add appropriate error checks in between.