Sendkeys(), Click() actions are not working for email field

Sendkeys(), Click() are not working for email field.But its working for password field. Please check the below code. and attached screenshot.

Email id field code is:


driver.findElement(By.xpath("//XCUIElementTypeButton[@name=‘Email’]")).click();
((IOSDriver)driver).hideKeyboard();
driver.findElement(By.xpath("//XCUIElementTypeButton[@name=‘Email’]")).sendKeys(“test”);

Password field code is:
driver.findElement(By.xpath("//XCUIElementTypeSecureTextField[@value=‘Password’]")).click();
((IOSDriver)driver).hideKeyboard();
driver.findElement(By.xpath("//XCUIElementTypeSecureTextField[@value=‘Password’]")).sendKeys(“raks”);

the locator should be XCUIElementTypeTextField not XCUIElementTypeButton

@Bilal_Jarwan thanks for the response.
Even its not working for this code as well.

driver.findElement(By.xpath("//XCUIElementTypeTextField[@value=‘Email’]")).click();
((IOSDriver)driver).hideKeyboard();
driver.findElement(By.xpath("//XCUIElementTypeTextField[@value=‘Email’]")).sendKeys(“test”);
driver.findElement(By.xpath("//XCUIElementTypeSecureTextField[@value=‘Password’]")).click();
((IOSDriver)driver).hideKeyboard();
driver.findElement(By.xpath("//XCUIElementTypeSecureTextField[@value=‘Password’]")).sendKeys(“raks”);

Displaying this error:

[JSONWP Proxy] Got response with status 200: {“value”:{“using”:“xpath”,“value”:"//XCUIElementTypeTextField[@value=‘Email’]",“description”:“unable to find an element”},“sessionId”:“A5A83E8A-D223-4831-A0ED-38BCBEE93BCE”,“status”:7}
[BaseDriver] Waited for 55942 ms so far
[JSONWP Proxy] Proxying [POST /element] to [POST http://localhost:8100/session/A5A83E8A-D223-4831-A0ED-38BCBEE93BCE/element] with body: {“using”:“xpath”,“value”:"//XCUIElementTypeTextField[@value=‘Email’]"}
[JSONWP Proxy] Got response with status 200: {“value”:{“using”:“xpath”,“value”:"//XCUIElementTypeTextField[@value=‘Email’]",“description”:“unable to find an element”},“sessionId”:“A5A83E8A-D223-4831-A0ED-38BCBEE93BCE”,“status”:7}
[BaseDriver] Waited for 57490 ms so far

Please help me any one. I am expecting quick response from any one. @Venkatesh_Akula, @Bilal_Jarwan, @freddy, @venkat4, @kumarsiva, @jagadeeshkotha,

try this and let me know if its working
By.xpath("//XCUIElementTypeOther/XCUIElementTypeTextField/XCUIElementTypeTextField")).sendKeys(“test”);
By.xpath("//XCUIElementTypeOther/XCUIElementTypeSecureTextField/XCUIElementTypeSecureTextField")).sendKeys(“raks”);

Hey karunakar, Use IOS driver type cast for entire test case not just for hidekeyboard.

mens

//means some where above where you are declaring the actual driver there itself do the type cast, then only element identification on IOS applies for every step.
//Not sure what code you have at driver delcartion, but make sure u typecast with IOS driver. some thing like
somedriver = (IOSDriver< WebElement >)driver;

// then use that somedriver in the below code

somedriver.findElement(By.xpath(“//XCUIElementTypeTextField[@value=‘Email’]”)).click();
somedriver.hideKeyboard();
somedriver.findElement(By.xpath(“//XCUIElementTypeTextField[@value=‘Email’]”)).sendKeys(“test”);
somedriver.findElement(By.xpath(“//XCUIElementTypeSecureTextField[@value=‘Password’]”)).click();
somedriver.hideKeyboard();
somedriver.findElement(By.xpath(“//XCUIElementTypeSecureTextField[@value=‘Password’]”)).sendKeys(“raks”);

Actually i have mentioned like this.
IOSDriver driver = new IOSDriver(new URL(“http://127.0.0.1:4723/wd/hub”),capabilities);
Now what should i change in code. @kumarsiva

That is fine, can you try once by giving 10 seconds wait before to Email click action. or alternatively interchange the steps of email and password up and down try again, let see any time lag is there before loading of all elements on screen

@kumarsiva
Am using below code is this ok or should i change anything in this

            File appDir = new File("src");
	File app =new File(appDir,"test.app");
	 
	DesiredCapabilities capabilities = new DesiredCapabilities();
	capabilities.setCapability("platformName", "iOS");
	capabilities.setCapability("platformversion", "11.0");
	capabilities.setCapability("deviceName", "iphone Simulator");
	capabilities.setCapability("automationName", "XCUITest");
       capabilities.setCapability(MobileCapabilityType.APP,app.getAbsolutePath());
       IOSDriver driver = new IOSDriver(new URL("http://127.0.0.1:4723/wd/hub"),capabilities);
      driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);
      
      driver.findElementByAccessibilityId("menuwhite48").click();
     driver.findElementByAccessibilityId("Login").click(); //Contact
     Thread.sleep(200);

    driver.findElement(By.xpath("//XCUIElementTypeTextField[@value=‘Email’]")).click();
    driver.hideKeyboard();
    driver.findElement(By.xpath("//XCUIElementTypeTextField[@value=‘Email’]")).sendKeys("test");
    driver.findElement(By.xpath("//XCUIElementTypeSecureTextField[@value=‘Password’]")).click();
    driver.hideKeyboard();

driver.findElement(By.xpath(“//XCUIElementTypeSecureTextField[@value=‘Password’]”)).sendKeys(“raks”);
Thread.sleep(90000);

That time 200 is in milli seconds means not even 1 sec, keep it for 10000 and execute once. may be giving wait will resolve the issue

Changed the thread sleep count, Event its displaying the same error.
Password field is working fine with the above code but am not able to enter the text in email id field. i don’t know the exact reason for that…
Please check the above mentioned code and correct me if anything wrong. @kumarsiva

Where should i add this line in this above code.
"< WebElement >)driver

Actually the above code should be

AppiumdDriver< WebElement> driver = new IOSDriver< WebElement>(new URL(“http://127.0.0.1:4723/wd/hub”),capabilities);

If i use this below line its displaying error like:
Code:
AppiumdDriver< WebElement> driver = new IOSDriver< WebElement>(new URL(“http://127.0.0.1:4723/wd/hub”),capabilities);

Error:
The Type AppiumDriver is not generic: it can not be parameterized with arguments
The Type IOSDriver is not generic: it can not be parameterized with arguments

NoteL I think this issue is because of the attached java client. Currently am using java-client-2.1.0.jar. Please look into this and give me the solution.

Yup that could be the reason, you can use latest version of java-client 4.1.1. Even after upgrading java-client, still if it is not working then alternatively you can try the below code in identifying Email. As you said password field is detecting fine, you can try to give below xpath for email field

//XCUIElementTypeSecureTextField[@value=‘Password’]/…/preceding-sibling:://XCUIElementTypeTextField[@value=‘Email’]

I found this error after changing the java client to 4.1.1
Multiple markers at this line
- The type org.openqa.selenium.remote.service.DriverService$Builder cannot be resolved. It is indirectly referenced from required .class files
- The type org.openqa.selenium.remote.http.HttpClient$Factory cannot be resolved. It is indirectly referenced from required .class files

@kumarsiva please give me solution for above error.