-1

After I search for a user in the search field, I get the user I searched Now I need to select this user that shown in the list

I tried with xpath and did not find the element ! could you help ?

So after I search for that user I need to click the first result checkbox

HTML Element code

Website screenshot

what I tried:

self.browser.find_element_by_xpath("/html[1]/body[1]/div[1]/div[4]/main[1]/div[3]/div[2]/section[3]/div[1]/div[2]/div[4]/div[2]/div[1]/div[1]/div[2]/div[1]/div[2]/div[2]/div[1]/div[3]/div[2]/div[2]/div[2]/div[1]/div[2]/div[1]/div[1]/div[1]/div[1]/div[2]/div[2]/div[1]/table[1]/tbody[1]/tr[1]").click()

WebDriverWait(self.browser, 10).until(EC.visibility_of_element_located((By.XPATH, "//div[contains(@class,'azc-grid-cellContent') and(contains(text(),'{}'))]".format(email)))).click()

Edit: Added a new photo

enter image description here

5
  • Your xpath is absolute xpath which is brittle. please share HTML in text format Commented Oct 13, 2021 at 9:54
  • please ask developer to add custom attributes, if your elements are like this. soon you will get disappoint on automation. add attribute like <div auto="checkbox">. this is the best way of doing automation. Commented Oct 13, 2021 at 9:56
  • @JayanthBala Im not the owner of the website im working on Azure Portal (portal.azure.com) Commented Oct 13, 2021 at 10:32
  • @cruisepandey How to past all html code in here ? its only allowing me pasting 30k words Commented Oct 13, 2021 at 10:33
  • Please upload in text format to file hosting web site and then share link with us here. Commented Oct 13, 2021 at 10:40

1 Answer 1

0

In case you need to click on the first presented result please try this:

WebDriverWait(self.browser, 10).until(EC.visibility_of_element_located((By.XPATH, "//tr[@aria-rowindex='1']//div[@data-bind]"))).click()

I'm not sure about this.
Need to see the actual web page with the dev tools for better suggestion...

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

2 Comments

can you help If I share my anydesk ? I tried your suggestion , but I did not work. And btw How to share all my html code ! StackOverflow is not allowing me past more than 30k
Anydesk is a good idea, but not when I work from the office and my boss is sitting behind me 😉 so maybe tomorrow.

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.