0

Given this xpath syntax

//div[@class="sk-circle-container"]

Can somebody convert it to find the div that has attr class sk-circle-container in the entire DOM as JQuery script?

This seems to not find anything, even if the element is there: div:contains(sk-circle-container)

ikiK
  • 6,328
  • 4
  • 20
  • 40
michael
  • 7
  • 5
  • If your looking for a div with `sk-circle-container` as class then use `div.sk-circle-container` `$('div.sk-circle-container')` – Carsten Løvbo Andersen Sep 15 '20 at 11:54
  • https://stackoverflow.com/questions/6453269/jquery-select-element-by-xpath – sebasaenz Sep 15 '20 at 11:56
  • @Carsten, it returns the following error : `selenium.common.exceptions.JavascriptException: Message: javascript error: missing ) after argument list` – michael Sep 15 '20 at 12:04
  • @michael the error says it all. You are missing `)` closing bracket in your code just check the console which line is it referring it to - :) – Always Helping Sep 15 '20 at 12:23
  • @Sebasaenz Did what the post desbribed but, when running `self.browser.execute_script('$(document).xpath("//div[@class="sk-circle-container"]");')` the following error is returned `selenium.common.exceptions.JavascriptException: Message: javascript error: missing ) after argument list` – michael Sep 15 '20 at 12:27
  • @Carsten, this is what is executed, no `)` is missing : `return jQuery('div.sk-circle-container $('div.sk-circle-container')').is(':animated');` – michael Sep 15 '20 at 12:32
  • might not be missing a `)` but is definetly broken. – Stender Sep 15 '20 at 12:36
  • Seems like it.. – michael Sep 15 '20 at 12:39

1 Answers1

0

Try this one:-

driver.get(" https://www.XYZXYZXYZ.com/");

List<WebElement> list = driver.findElements(By.xpath("//div[@class='sk-circle-container']"));

OR

    List<WebElement> myList = driver.findElements(By.className("sk-circle-container"));
ListIterator<WebElement> myListIterat= myList.listIterator();
Saurin Vala
  • 1,898
  • 1
  • 17
  • 23