2

https://www.n11.com/telefon-ve-aksesuarlari/cep-telefonu-aksesuarlari

In this web site, I am trying to click (next page button)

I want to catch this line

<a href="https://www.n11.com/telefon-ve-aksesuarlari/cep-telefonu-aksesuarlari?pg=3" class="next navigation"></a>

I am writing this code in program

data=driver.find_elements_by_class_name("next navigation")

My question is about this problem.. it is not working

Mate Mrše
  • 7,997
  • 10
  • 40
  • 77

2 Answers2

16

data=driver.find_elements_by_class_name() accepts only single class name.

class="next navigation" defines two classes, next and navigation.

So you are only able to search for next or for navigation like this:

elementObj = driver.find_elements_by_class_name("next")
elementObj = driver.find_elements_by_class_name("navigation")

To find a element by multiple class names use xpath or cssSelector: Find div element by multiple class names?

elementObj = driver.findElement(By.cssSelector(".next.navigation"));
micharaze
  • 957
  • 8
  • 25
0

By.CLASS_NAME does not seem to work if there is space in the class name like in your case "next navigation"

Workaround should be to use CSS_SELECTOR instead of CLASS_NAME and using . instead of space

data = driver.find_element(By.CSS_SELECTOR, ".next.navigation")
Prakash Dahal
  • 4,388
  • 2
  • 11
  • 25