0

I'm working on a python selenium script. I find some elements in firefox by the command :

large_bu = driver.find_elements_by_class_name('butik.large.col-lg-12.col-md-12.col-xs-12')

and len(large_bu) returns 20.

But when i try this in Chrome Driver len(large_bu) returns 0. How can i find this elements in Chrome Driver ?

Thanks for your replies. sorry for my bad English.

1 Answers1

1

This is an issue between different versions of selenium. find_elements_by_class_name doesn't allow multiple classes anymore, you should use find_elements_by_css_selector instead:

driver.find_elements_by_css_selector('.butik.large.col-lg-12.col-md-12.col-xs-12')

That should return a list with all the matches for that CSS selector.

Sean Breckenridge
  • 1,932
  • 16
  • 26
  • Works in Chrome Driver. But the other format works in firefox driver...Does element search queries differ between different browser? – Deepak M Dec 17 '18 at 00:50
  • 1
    @DeepakM It doesn't surprise me that the other version works in Firefox, the capabilities change depending on which browser you're using or which version of the WebDriver you're on. If you're using the correct format for the browser you're on, the number of elements should be the same. – Sean Breckenridge Dec 17 '18 at 02:54