0
votes

Below is a text input box Search for in selenium, i can first find the element, input data. but on the front end i dont see any data inputted

I am not sure why my UI doesnt show data being typed by the webdriver . no error in the code log

System.setProperty("webdriver.chrome.driver",
            "C:\\Users\\rahul\\Downloads\\chromedriver_win32_83\\chromedriver.exe");
    driver = new ChromeDriver();
    driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
    driver.get("http://testingapp.workspez.com");
    driver.manage().window().maximize();
    WebElement username = driver.findElement(By.id("field_email"));
    WebElement password = driver.findElement(By.id("field_password"));
    WebElement login = driver.findElement(By.xpath("//*[text()='Log In']"));

    username.sendKeys(Keys.CONTROL + "a");
    username.sendKeys(Keys.DELETE);
    password.sendKeys(Keys.CONTROL + "a");
    password.sendKeys(Keys.DELETE);

    username.sendKeys("[email protected]");
    password.sendKeys("Sujeet@19");
    login.click();
    try {
        Thread.sleep(2000);
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
    
    
    WebElement generalInfo = driver.findElement(By.xpath("//*[text()='General Info']"));
    generalInfo.click();
    try {
        Thread.sleep(2000);
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
    WebElement Contacts = driver.findElement(By.xpath("//*[text()='Contacts']"));
    Contacts.click();
    
    try {
        Thread.sleep(2000);
    } catch (InterruptedException e) {
        e.printStackTrace();
    } 
    //find search for 
    WebElement newlyaddedcontact1 = driver.findElement(By.xpath("//*[text()='Search for']"));
    JavascriptExecutor executor1 = (JavascriptExecutor) driver;
    executor1.executeScript("arguments[0].click();", newlyaddedcontact1);           
    JavascriptExecutor executor = (JavascriptExecutor) driver;
    executor.executeScript("arguments[0].value='searchcontact';", newlyaddedcontact1);
    WebElement search = driver.findElement(By.xpath(".//*[@class='MuiButtonBase-root MuiIconButton-root']"));
    search.click();

how to access that webpage

1.login into http://testingapp.workspez.com

  1. username :[email protected] password: Sujeet@19

  2. click general info tab on top, then click contacts 'tab'

  3. you will see the search for box.

enter image description here

1
can you share link of page so that i can go through and tell what issue is ? - Justin Lambert
first you need to click into that field then you can sendkeys to that field .(is this auto filled option) - Justin Lambert
the send keys doesn't work. Please look at the instructions above on access the page under 'how to access that webpage' thanks alot! @JustinLambert - Rahul SK
your search for does not getting values because web is behaving like that i entered values but does not getting from keyboard - Justin Lambert
How are you inputing data into page , you told search for option does not getting user values right ? - Justin Lambert

1 Answers

0
votes

I thing You need to change you Xpath.Because whatever you write XPath this is for a label you need to write for input control so i update your code.

IWebElement newlyaddedcontact1 = driver.FindElements(By.XPath("//input[contains(@class,'MuiInput-input')]")).ToList()[0];
JavascriptExecutor executor1 = (JavascriptExecutor) driver;
executor1.executeScript("arguments[0].click();", newlyaddedcontact1);           
JavascriptExecutor executor = (JavascriptExecutor) driver;
executor.executeScript("arguments[0].value='"+name+"';", newlyaddedcontact1);

Please Try this code. I write in C# language.