When we enter text in google search textbox it auto-suggest the options, the objects changes.

Now I want to click the Search button which was earlier Google Search.

I have created the Google Search button with name property and btnK is the value.

Now as the property changes to btnG, so how I can retrieve the properties and then use this property value to identify the object.

This sounds like dead-end because object changes and so we cannot retrieve it's value. I believe we can use dynamic property here. But I am stuck here! I am using Selenium webdriver with Java.

Any help is appreciated!

1 Answer 1


Given that in this specific case the name property is dynamic, I would recommend trying an alternative selector that is static instead. For example, using google.com, we can select the button using the code below.

driver.findElement(By.cssSelector("input[value='Google Search']"))

If you do wish to stick with checking a dynamic value, you can check for part of the name using contains in the css selector.


This should pull in both the google search button and I'm feeling lucky button. I recommend the approach further above that uses value in the selector because it is more specific.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.