I'm trying to click on an icon that appears on the page however despite trying everything I can think of I keep getting the following error:
waiting for selector "[aria-label="Comment"]"
selector resolved to 2 elements. Proceeding with the first one.
selector resolved to hidden <svg role="img" width="24" height="24" fill="#8e8e8e"…>…</svg>
attempting click action
waiting for element to be visible, enabled and stable
element is visible, enabled and stable
scrolling into view if needed
element is not visible
retrying click action, attempt #1
waiting for element to be visible, enabled and stable
element is visible, enabled and stable
scrolling into view if needed
done scrolling
element is not visible
retrying click action, attempt #2
waiting 20ms
waiting for element to be visible, enabled and stable
etc etc etc.
So it looks like the element is hidden although I can't see any sign of that in the html....attached.
Any help greatly appreciated.
enter image description here
shorter version
page.locator('svg[aria-label="Comment"] >> nth=1').click();
You can use nth locator's method to get second element:
page.locator('svg[aria-label="Comment"]').nth(1);
or shorter version:
page.locator('svg[aria-label="Comment"] >> nth=1');
Keep in mind that's zero-based numbering.
Related
I am having a scenario to click on a svg element, tried the following code, it is not throwing any error. it is clicking but the element state is not changed. tried force click also.
cy.xpath("(//app-job[contains(#class,'selected')]//highcharts-chart[#id='GMF_K_CHART']//*[name()='svg']//*[name()='g' and #class='highcharts-series-group']//*[name()='g' and #clip-path='none' and not(#visibility)])[4]//*[name()='path'][4]")
.click()
Graph how displaying after clcik
But it should be if clicked properly
I tried multiple combination of clicks
`.click({force: true})
.click()
.trigger('change')
.trigger('focus')
.click()`
Please make sure that you're selecting the svg element and then, use trigger() to click on that element.
cy.get('<svg element>').trigger('click')
It seems that cypress expects that click is preceded by mouse hover. In that case, make sure that cypress hovers the mouse over the point (the tooltip must fire) and then let the cypress perform a click event on the point.
cy.get(".highcharts-container")
.get(".highcharts-point")
.eq(1)
.trigger("mousemove");
cy.wait(1000);
cy.get(".highcharts-container")
.get(".highcharts-point")
.eq(1)
.trigger("click");
If that didn't work, it would be possible that some cypress event is not correctly triggered; in that case try the following workaround:
cy.get(".highcharts-container")
.get(".highcharts-point")
.eq(1)
.trigger("mousemove").trigger("mousemove");
cy.wait(1000);
cy.get(".highcharts-container")
.get(".highcharts-point")
.eq(1)
.trigger("click").trigger("click");
I am learning mobile automation and I came across a scenario some thing like this
Launch chrome app in iOS
Load https://www.google.com
Hold/Press and pull down banner web element on the web page which will display some overlay with three options 'New tab, Reload & Close tab' (note: overlay will lost on releasing the banner web element)
Tap on the new tab button
So far I have written below script in python
def Test(self, driver_provider):
single_tap = appium.webdriver.common.touch_action.TouchAction(driver_provider.driver)
element = driver_provider.driver.find_element_by_accessibility_id('NTPHomeFakeOmniboxAccessibilityID')
single_tap.tap(element=element).perform()
element.send_keys('https://www.google.com')
single_tap.tap(element=driver_provider.driver.find_element_by_accessibility_id('Go')).perform()
time.sleep(1)
#Press banner and pull down will display the over scroll actions
#Then move to left to tap on the add button
banner_element = driver_provider.driver.find_element_by_accessibility_id('banner')
screen_size = driver_provider.driver.get_window_size()
height = screen_size.get('height')
width = screen_size.get('width')
single_tap.press(banner_element, x=banner_element.size.get(
'width')/2, y=banner_element.size.get('height')/2).wait(1).move_to(banner_element,
x=width/2, y=height/2).wait(0.5).move_to(banner_element, x=0, y=height/2).release().perform()
for some reason press and move_to actions are not happening and there is no error returned as well, I am not clear what went wrong here. Please share your view on what went wrong thanks.
it's failing to perform press and move to because of wait value is very small. When I use the wait(500) then the press and move to is happening.
single_tap.press(banner_element, x=banner_element.size.get(
'width')/2, y=banner_element.size.get('height')/2).wait(500).move_to(banner_element,
x=width/2, y=height/2).wait(500).move_to(banner_element, x=0, y=height/2).wait(500).release().perform()
As, you can see in the above snippet, when i try to locate value e.g.. '16' in this case or i would like to scroll to select any other value. I am unable to select or scroll from this window. Is it possible to select value using robot framework with appium library. suggestions are most welcome.
One approach you can follow to do this is as follows:
First get the position of the element which is visible(In your case 16).
If you want to scroll down click on the element above 16 by substracting some pixels from the location you get in step 1.Verify for the element you want is highlighted or not.
We're using Appium with iOS Simulator and test functions written in Java.
We have an iOS App with screen 1 containing a UICollection view, and tell Appium to click on one of its elements.
This opens screen 2 (and the scrolling animation takes about 500 ms), which also contains an UICollection view. I want to find out the size of the UICollection view of the second screen with Appium.
The problem is that Appium is too fast and executes the findElements() method directly after the click, which causes it to find the UICollection view of the first screen.
clickOnElementOnFirstScreen();
webDriver.findElements( By.className( "UIACollectionCell" ) ).size();
// is supposed to find the UICollection view on the second screen,
// but actually finds the UICollection view on the first screen
Appium provides several waiting functions. However as far as I can see all of them are intended to be used in this fashion:
"wait until element at location X / with name X becomes visible"
If I try to use these waiting functions, they don't wait at all because they immediately find the UICollection view of the first screen, which has the same location and name as the one on the second screen.
The only solution I have found is to use Thread.sleep:
Thread.sleep(1000);
webDriver.findElements( By.className( "UIACollectionCell" ) ).size();
But we don't want to use Thread.sleep in code that will run on the client's server on hundreds of tests.
We might be able to modify the App and enter metadata into the views so that Appium is able to distinguish them, but this situation occurs in several places and the App is being programmed by the client, so we want to avoid this too.
What is a simple and safe way to wait for the new screen to appear, without modifying the code of the iOS App?
I have found only dirty workaround for this issue.
static waitFor(Duration duration) {
try {
def WebDriverWait wait = new WebDriverWait(mobileDriver, duration.standardSeconds)
wait.until(visibilityOfElementLocated(By.xpath("//Fail")))
//Wait until false case is visible to ensure proper timeout
} catch (Exception e) {
}
}
Another workaround/solution that has been posted on the Appium forums is:
First search for some other element that distinguishes the 2. screen from the 1. screen; once that is visible, it's safe to search for the originally desired element.
I want to add a search field inside my custom keyboard that allows the user to search for content which can then be input into the main text document for which the keyboard is being displayed.
However, calling -becomeFirstResponder on the UITextField object causes a 3-4 second lag during which no input is accepted. The same thing happens if I call -resignFirstResponder. I can set the text property of the text field just fine, but that means that there is no caret, and the text is truncated to fit.
On calling (become|resign)FirstResponder, I get the following messages in the log:
2014-10-28 13:39:50.920 Giffy KB[2073:514844] Received 0 images
2014-10-28 13:39:57.942 Giffy KB[2073:514745] <_UIRemoteInputViewController: 0x14762a030> timed out waiting for fence barrier from com.theappical.giffage.giffagekb
2014-10-28 13:39:58.446 Giffy KB[2073:514745] View service did not balance fencing 'begin' messages with 'end' messages within a second; timing out.```
Other third party keyboards seem not to use textfields (they use custom views instead). Does that mean this is a bug at Apple's end, or is there something I can do to resolve it?
Filed a bug report with Apple for the same, ended up faking a text field using a UILabel. As of now (iOS 8.1 latest), this issue has yet to be resolved.