0

I am trying to scrape an element from a page using Selenium Web Driver and I cant seem to figure out how to grab a certain text. I am trying to get the sting " 35330100: Oil and gas drilling rigs and equipment" in this line of code below.

<td class="tRight altRow">35330100: Oil and gas drilling rigs and equipment</td>

the syntax that I used in my notebook which is throwing me an error is as below

primary = driver.find_element_by_class_name("tRight altRow")

Any help would be helpful.

Many thanks in advance.

Andersson
  • 51,635
  • 17
  • 77
  • 129
spak
  • 253
  • 1
  • 2
  • 12

1 Answers1

-1

Afaik there is no method called find_element_by_class_name available thru selenium webdriver. Use something like this:

driver.findElement(By.cssSelector('.tRight.altRow'));

Edit: Didn't notice the OP's question was about Python. Here's the edit - driver.find_elements_by_css_selector('.tRight.altRow')

  • No. There is a method called `find_element_by_class_name`. That's not an issue. Also note that your syntax is definitely not a Python – Andersson Aug 14 '18 at 20:55
  • @Andersson Oh never mind, I thought OP was using the Java version. You can try doing it with CSS Selectors instead... it should look something like - `driver.find_elements_by_css_selector('.tRight.altRow')` – Satya Sampathirao Aug 15 '18 at 21:52