3

I am scraping some data from this link https://www.vbgov.com/property-search#DetailView=14760123360000. But i am unable to simulate click event on "Sales History & Tax Information" tab using webdriver Selenium and python.

driver.get("https://www.vbgov.com/property-search#")

searchBox1 = driver.find_element_by_id("consolidated-search-query")

searchBox1.send_keys("1124 LUKE DR")

searchBox1.send_keys(Keys.ENTER)

driver.implicitly_wait(5)

link = driver.find_element_by_xpath('//*[@id="property"]/tbody/tr/td[2]/a')

link.click()

elem = driver.find_element_by_xpath('//*[@id="property-counts"]/h4')

tab = driver.find_element_by_partial_link_text("Sales History & Tax Information")
tab.click()
1
  • What error are you seeing, if any? Is find_element_by_partial_link_text() raising an error? Is click()? Or is it simply that nothing appears to happen in the browser? Commented Feb 11, 2018 at 21:30

2 Answers 2

1

You are trying to click on the 'Sales History & Tax Information tab' and its happening too , but it is happening while the page loads and after page load by default it is navigate to 'land/Building Information' tab. So here i am waiting for page to load before clicking on 'Sales History & Tax Information tab' by waiting till 'property blue prints' loads.

Using time.sleep before clicking 'Sales History & Tax Information tab' also works here but not preferable.

searchBox1 = driver.find_element_by_id("consolidated-search-query")
searchBox1.send_keys("1124 LUKE DR")
searchBox1.send_keys(Keys.ENTER)
driver.implicitly_wait(5)
link = driver.find_element_by_xpath('//*[@id="property"]/tbody/tr/td[2]/a')
link.click()
elem = driver.find_element_by_xpath('//*[@id="property-counts"]/h4')
wait.until(EC.presence_of_element_located((By.XPATH, "//*[text()='Land Information']")))
wait.until(EC.visibility_of_element_located((By.XPATH, "//div[@class='band visible ready']")))
wait.until(EC.visibility_of_element_located((By.XPATH, "//a[text()='Sales History & Tax Information']"))).click()

Hope this will solve your problem.

Sign up to request clarification or add additional context in comments.

Comments

1

To simulate click event on Sales History & Tax Information tab, you can use the following line of code :

driver.find_element_by_xpath("//ul[@class='navbar nav-pills nav hasOverflow']//li[@role='tab']/a").click()

1 Comment

is <selenium element>.click() superior in any form to executing javascript, like driver.execute_script(document.querySelector(...).click())?

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.