RamaKrishna
RamaKrishna

Reputation: 101

Is it true that DIV elements cannot be clicked with selenium Web Driver?

Is it true that DIV elements cannot be clicked with selenium Web Driver?

For Instance, I'm unable to click on delete button in Gmail

Am unblae to thid delete button

Am trying to locate the elemnt using XPATH = //div[@aria-label='Delete']

Below is the HTML code:

here, class names and id's are dynamic which changes for every session. Imean, for every Login and Logout. I want my script to be Robust to run at any time.

Upvotes: 0

Views: 240

Answers (3)

cyildirim
cyildirim

Reputation: 641

It may derive because of gmail has async structure. You may wait to finish request after page load and after select action. If you can share code flow we can examine together.

Upvotes: 0

Nilamber Singh
Nilamber Singh

Reputation: 874

Have you tried using a different attribute ? For e.g. you can use

//div[@data-tooltip='Delete'] 

or

//div[@data-tooltip='Delete']/div/div

Upvotes: 0

Paul Redmond
Paul Redmond

Reputation: 3296

You can by class name or ID, e.g. with class:

driver.findElement(By.className("class")).click();

Or by element name:

driver.findElement(By.ByTagName("div")).click();

Or find the parent or child a tag.

Upvotes: 1

Related Questions