2

I'd like to download the primary parcel layer from this website.

First step is to click the "Add/Remove Item" button, but I am having trouble locating it. For this button, the Inspect Element window looks like this:

enter image description here

The relative XPath for this is

//div[@data-dojo-attach-point='itemAddStateNode']

The absolute XPath for this is

/html[1]/body[1]/div[4]/div[1]/div[2]/div[1]/div[1]/div[2]/div[2]/div[1]/div[1]/div[1]

I've tried using both by going:

driver.find_elemet_by_xpath("XPath as above")

I've also tried using its id:

driver.find_elemet_by_id("K/widgets/Tooltipify_10")

but they did not work (NoSuchElementException).

What I want to do is to make sure that this button is "ON", in which case, the class name is

class = ........... is-in-collection

and if not, turn it on.

Originally I was going to locate the button and click it to turn it on, but if there is a way to check the status of the button, that's probably better, as this site seems to retain the setting from the last visit.

Can anyone please help me on this?

Thanks in advance.

1 Answer 1

1

There are several button with the data-dojo-attach-point='itemAddStateNode' attribute on you web page so make sure you are locating the correct one.

possibility is the number in id=K/widgets/Tooltipify_10 is dynamic it may change if number of component gets add on page

You can use combination of attribute in CSS selector as below

div[id='K/widgets/Tooltipify_10']>div[data-dojo-attach-point='itemAddStateNode']

eg. Add Icon

driver.find_element_by_css_selector("div[id='K/widgets/Tooltipify_10']>div[data-dojo-attach-point='itemAddStateNode']")

Remove Icon

driver.find_element_by_css_selector("div[id='K/widgets/Tooltipify_10']>div[data-dojo-attach-point='itemRemoveStateNode']")

You can check the condition which one is currently displaying e.g

element = driver.find_element_by_css_selector("div[id='K/widgets/Tooltipify_10']>div[data-dojo-attach-point='itemAddStateNode']")
if element.is_displayed():
  print "Add Button is There"
else:
  print "Element not found"

For Remove:

element = driver.find_element_by_css_selector("div[id='K/widgets/Tooltipify_10']>div[data-dojo-attach-point='itemRemoveStateNode']")
if element.is_displayed():
  print "Remove Button is There"
else:
  print "Element not found"
0

Your Answer

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

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