Reputation: 23
I am trying to automate salesforce, however i am having some trouble with the locators. I am using Python and selenium webdriver to do this.
I am trying to click on this element (snippet given):
< th scope = "row"
class = " dataCell cellCol1 " > < a href = "javascript:srcUp(%27%2F0019E00000SLiUQ%3FsrPos%3D0%26srKp%3D001%26isdtp%3Dvw%27);"
data - seclke = "Account"
data - seclkh = "73556054e04c9691f20b5b34809356fd"
data - seclki = "0019E00000SLiUQ"
data - seclkp = "/0019E00000SLiUQ"
data - seclkr = "1"
onmousedown = "searchResultClick.mousedown(this, event)" > Harris Kemp < /a></th >
however, for some reason it can't locate it.
I have tried different solutions that i found online and none of them seem to work.
Here is my code:
driver.switch_to.frame(1)
# driver.switch_to.frame(driver.find_element_by_id("history-iframe"))
# mouseDown() // i entered the location of the element here
# pyautogui.click() // i entered the location of the element here
Here is another way that I tried:
elem = driver.find_element_by_xpath("//a[@data-seclkr='1']")
driver.execute_script("arguments[0].click();", elem)
I have used all different xpaths available and it still won't click on it.
It would be really grateful if someone could help out please.
I have attached the full html body image here
Upvotes: 2
Views: 303
Reputation: 3471
To locate the "Edit" element, you could do:
elem1= driver.find_element_by_xpath("//td[@class='actionColumn']")
elem1.find_element_by_xpath(".//a[@class='actionLink']").click()
if you want to click "Harris Kemp", try:
elem1= driver1.find_element_by_xpath("//th[@scope='row']")
elem1.find_element_by_xpath(".//a[@data-seclke='Account' and text()='Harris Kemp']").click()
Upvotes: 3
Reputation: 2886
Can you pick a simple a tag from the site and try something like the below?
Let's say that this is the HTML script:
<div id='a'>
<div>
<a class='click'>abc</a>
</div>
</div>
your python script should be:
driver.find_element_by_xpath("//div[@id='a']//a[@class='click']")
The output should be:
<a class="click">abc</a>
and then try to put the .click()
in the end of your python code
Upvotes: 1