Can't click on web element with flutter appium driver that is covered by other element - flutter

I tried to test a webview in flutter app using flutter appium driver and faced a problem:
In a webview I have a text, that is placed in two lines. Because of that placing text is covered by another element.
I tried 3 approaches:
1.appium driver: mouse.moveTo then mouse.click.
Solution with mouse.moveTo then mouse.click did not work because appium need other parametr called duration, that is not included to parameters in our appium_driver.
2. Used flutter inspector to locate elements on the webview - solution was not succeed because this webviews are external and were not covered by any flutter overlay.
3. Clicking by bounds
Got all objects from the webview with TESTWorld().appiumDriver.pageSource. Found out that we have the xml with all objects on webview with properties as bounds,text. Made a list with 3 objects of “MyString“ string and clicked on them one by one with click() method from appium_driver. Second element “MyString“ is clickable, appium can click on it, but first instance of this string is in two lines, so this element is part of other big element, that’s why appium_driver can’t click on it.
Maybe someone knows another approach?

Because of that placing text is covered by another element
In a particular case, it sounds like an AUT issue. Appium uses WebDriver API for testing WebView and it is expected to not be able to interact with the overlapped element.
If there is no way to address and fix it in the app, you can try JS to send a click action (the same way we do in Webdriver):
WebElement textElement = driver.findElement(...);
JavascriptExecutor jsEx = (JavascriptExecutor)driver;
jsEx.executeScript("arguments[0].click();", textElement);

Related

Locate elements inside Shadow-root using Protractor

Most of my application's elements are under shadow-root(open). I need to automate them using Protractor framework. deepCSS didnt work out. Please help me with automating these elements - mostly click.
I have to click on shadow-root elements using my protractor automation framework. I tried deepCSS, xpath etc. nothing worked.
var spanElem = element.all(by.deepCss('.heading'));
spanElem.click()
//browser.actions().mouseMove(spanElem).click().perform();
Similar questions:
deepCss is failing to identify an element inside the shadow root in Protractor
Protractor: Unable select input element inside a shadow DOM (Polymer) using by.deepCss('input')
It seems Shadow DOM is not yet well supported by protractor. The Second question has an answer pointing to this issue https://github.com/angular/protractor/issues/4367 and a workaround for adding a custom locator by.addLocator('css_sr', (cssSelector: string, opt_parentElement, ..... I confirm this works in my case too.

Click button is not working in protractor

I am new to angular world. I am in process of automating the angular 2
application but I am having hard time to click a button.
Options tried:
I used various selectors like xpath, CSS, buttonText but none of them is working, s/m throws a timeout message or unable to find a selector.
When I try to print the element in console it is displaying as object object.
Do I need to return the value in format of string and then attempt to click?
Or
Do I need to add any require plug in from NPM ? Please let me know
script snippet:
var resubmit=element.all(by.xpath("//BUTTON[#_ngcontent=''][text()='resubmit']")).get('0');
console.log("return"+resubmit);
resubmit.click();
Wait untill element is become clickable and then click. You do it by following:
EC=protractor.ExpectedConditions;
var resubmit=element.all(by.buttonText('resubmit')).get('0');
browser.wait(EC.elementToBeClickable(resubmit), 15000,'Not Clickable'));
resubmit.click();

One Click vs Two Clicks

Scenario:
Testing web application using Protractor
Element needs to be clicked on to open another page
Designed the test to have one click on the element
Issue:
Sometimes elements needs one click and the test passes but if I run it again the same element needs double clicks
This is causing my test to fails randomly
I verified this by changing the command to have a double click in protractor and it passed.
This is causing inconsistency as I don't know when the element needs one or double clicks.
Any Suggestion is appreciated?
You may just need to put the element into focus explicitly via mouseMove() and then issue a click() action:
browser.actions().mouseMove(elm).click().perform();
Inconsistency might be because of element is not yet ready to click. So you need to wait until element become clickable and click it. Below code will help you in achieving consistency.
Code Snippet:
var EC = protractor.ExpectedConditions;
var elementToBeClick=element(locator);
var timeOut=10000;
browser.wait(EC.elementToBeClickable(elementToBeClick), timeOut).
thenCatch(function () {
assert.fail(' target element is not clickable');
});
elementToBeClick.click();
you can use browser.executeScripts to inject native javascript code into the browser and click the required button. this will execute the click event on the required element that you pass into the function
try the below code,
var elementToBeClick=element(locator);
browser.executeScript("arguments[0].click()",elementToBeClick.getWebElement())

"Send" button popup not appearing correctly

I'm using the Facebook Like/Send buttons along with dynamically generated HTML (loaded via AJAX requests). I've found that even though the Send button works fine when the element exists on page load, dynamically created Send buttons aren't working correctly. Clicking the button activates it and the button greys out, but the popup doesn't appear.
Here is a demonstration of what is happening: http://jsfiddle.net/Daniel15/VxpSj/
Any suggestions?
Thanks!
Yes, I can confirm the problem from your fiddle.
function addLikeButton()
{
// […]
FB.XFBML.parse(newEl);
document.getElementById('container').appendChild(newEl);
}
For some reason, this seems to be “the wrong way around”. Reverse the order of these two lines – put the new element into the DOM first and let FB.XFBML.parse parse it afterwards, then (from my test with your fiddle) it seems to work in the desired way.

Opening a new Window with a Widget in GWT

Before you start shooting me down i have checked for answers and i have googled till my fingers bled but i havent been able to find a simple, concise answer. So im asking again for all those that might have this problem.
Question: how to open a new window with a formpanel in side.
Context: i have an app that lists lots of items, i want someone to edit an entry, i want a new window to open so they can edit properties then hit save. A standard thing you find in a lot of applications.
Architecture:
I have one client module called UI, it has a dozen classes that draw widgets and fill a main area when selected from a menu. I have a single html page called UI.html which has the tag in the head. Thats it.
Options Ive Seen
Call Window.Open() but you need to define a html file. I dont have one. I can create an empty one but how do you inject a widget in to it ?
use jsni $wnd to create a new window and get a reference to it. But how do i inject a form panel into it ??
use a popuppanel. They look sucky - plus if opening a window through JS is quite simple i would expect it to be in gwt.
Maybe im miss understanding how to use GWT i dont know.
Any help would be appreciated
Thanks
The way i got this to work is as follows:
i wrote a jsni method to open a new window
public static native BodyElement getBodyElement() /*-{
var win = window.open("", "win", "width=940,height=400,status=1,resizeable=1,scrollbars=1"); // a window object
win.document.open("text/html", "replace");
i added a basic body to the new window and returned the body element
win.document.write("<HTML><HEAD>"+css1+css2+"</HEAD><BODY><div class=\"mainpanel\"><div style=\"width: 100%; height: 54px;\"><div id=\"mainbody\"class=\"mainbody\" style=\"width: 100%;\"></div></div></div></BODY></HTML>");
win.document.close();
win.focus();
return win.document.body;
}-*/;
i then called this method from my main java method
BodyElement bdElement = getBodyElement();
I then injected my panel which has lots of widgets into the returned body element
SystemConfiguration config = new SystemConfiguration(); bdElement.getOwnerDocument().getElementById("mainbody").appendChild(config.getElement());
I agree with Bogdan: Use a DialogBox.
If you can't, you Window.open() as you mentioned in option 1:
Create another GWT module, and form.html that will load it
Window.open("form.html?entry=54")
Have the form gwt module read from the URL, load the entry, allow it to be edited, and provide Save and Cancel buttons
Close the popup when Save or Cancel is clicked
Can't you just use a DialogBox?
Example