Hello,
I am trying to edit and insert the email field in existing native contact but while doing so I am getting the error “org.openqa.selenium.NoSuchElementException: An element could not be located on the page using the given search parameters”.Whereas if I try to create a new contact and send the values to the same element it’s getting executed successfully.
I have verified the element properties using the UI automator in both the cases and found to be same(Refer Image “UI Automator Viewer.png”).
Below is the script with which I have tried for detecting the element:
Also I tried to use Appium Inspector on mac but that was also not helpful.Below is the command:
- driver.findElement(By.xpath("//android.view.View[1]/android.widget.FrameLayout[2]/android.widget.FrameLayout[1]/android.widget.LinearLayout[1]/android.widget.ScrollView[1]/android.widget.LinearLayout[1]/android.widget.LinearLayout[1]/android.widget.LinearLayout[1]/android.widget.LinearLayout[1]/android.widget.LinearLayout[2]/android.widget.LinearLayout[1]/android.widget.LinearLayout[1]/android.widget.LinearLayout[1]/android.widget.LinearLayout[1]/android.widget.LinearLayout[1]/android.widget.EditText[1]")).sendKeys("[email protected]");
It would be helpful if you can look into this.
Hi Mitesh
Following tricks might be useful for you
-
Use Nexus or rooted device with uiautomatorviewer to get resource id and then refer particular element as follow
AppiumDriver driver;
driver=AndroidDriver(urlObject,capabilitiesObject);
MobileElement mobileElementEmail=(MobileElement) driver.findElemenetById(“YOUR RESOURCE ID”);
-
List<WebElement> elementsList=driver.findElementsByClassName("android.widget.EditText");
for(WebElement webElement: elementsList)
{
if(webElement.getText().equals("Email"))
{
//do your work
}
}
- Besides this ensure that your device snapshot is clearly visible while testing , it might be hampered by keyboard or any other opaque message or translucent elements.
Thanks Jimit for the reply.
I tried implementing the suggested solutions but was still facing the same issue.Below are the issues which I faced during the implementation of solutions:
-
Use Nexus or rooted device with uiautomatorviewer to get resource id and then refer particular element as follow:Unable to find resource id from Nexus device also.Refer to the below attached image:![](//discuss.appium.io/uploads/default/687/e9f5075387a4f39e.png)
-
Still facing the same issue i.e.if I create new contact script is getting executed successfully but when I tried to update the existing contact, script got failed while using sendkeys command to email field
-
Here I have already tried using driver.hideKeyboard() command before the step where script is getting failed
2nd case works fine for me not getting your problem here, I could help you out if you describe more or show your element accessing here.