简体   繁体   中英

selenium web driver does not return the value from cssSelector in java

I have this jQuery selector as below.

jQuery("html body div input[name='customer_name']").val();

According to that I have created the selector for selenium as below.

By cusNameTxtField = By.cssSelector("html body div input[name='customer_name']");

First expression giving me the expected output in the browser console, but using the second expression it returns null value. Is there any issue with the second expression ? And I am getting the String values as below in the java code.

String fieldText = waitForExpectedElement(cusNameTxtField, 10).getText();

鉴于这是一个input元素,您可能想尝试

waitForExpectedElement(cusNameTxtField, 10).getAttribute("value");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM