How to click element on pseudo element ::after in Robot Framework - xpath

I would like to Click button at ::after but I don't know how to create xpath from pseudo element
I try this way //em[#class='x-btn-split']::after but it's not work.
Please anyone help.

You can use directly id='ext-gen33'. But if you want xpath only then include 2 attribute if there are many matching buttons
xpath = //button[#type='button' and #id='ext-gen33'].

Related

XPath for "Onclick" attribute

I have to perform a click event on one of the option in a drop down menu on a web page, here is my absolute path for the element.
Absolute Path:-
And I have tried Xpath to find the element:-
All the combination of Xpaths that I tried are not working.
Please do suggest me if you have any solution for the same?
Many Thanks,
Shruti
Try with these Xpaths:
//a[#data-original-title='Excel']
//a[#alt='Excel']
//a[text()='Excel']

Appium. Usage of Xpath axes in locator. Find sibling/parent/child/etc elements in context of curtrent element

Is it possible to find sibling/parent/child/etc mobile elements in context of existing mobile element.
For example I have basic element:
MobileElement mobileElement = driver.findElement(By.xpath("//any/xpath/locator"));
Then I need to find following sibling element.
In Selenium I could use similar code:
MobileElement nextMobileElement = mobileElement.findElement("following-sibling::nextelement['any conditions']");
But in appium I getting NoSuchElementException.
What is the proper syntax for usage of xpath axes in Appium to locate elements in defined above way?
In general if you want to find element under a parent element using xpath, add a . to the xpath to say that the child element xpath to be searched under the given parent element. So in your case you can try something like :
mobileElement.findElement(By.xpath(".(xpath of the child element)")
For example mobileElement.findElement(By.xpath(".//div[#class='xyz']")
Solution found in next way:
When appium is unable to select element by its name, i.e. there an element <android.widget.ViewAnimator ....>, then you can view it's "class" attribute, and it will contain an identical text: class="android.widget.ViewAnimator". So you can build your Xpath complicated locators based on this attribute. In case of Xpath axes it will look like this: //some/xpath/preceding-sibling::*[#class='android.widget.ViewAnimator'].
Appium supports XPath as WebDriver does. Make sure your XPath is correct, you can test it in appium-desktop. Following-sibling was working for me without any issues.
When Appium is not able to process XPath expression, you should get the related exception.

Xpath or CSS : Trying to create either one

I am trying to capture "Featured Courses" using either an xpath or CSS selector on the following link qaclickacademy website. Below is what I have tried.
By.xpath("//div[contains(concat(" ",normalize-space(#class), 'text-center'), " Test ")]");
Would you like to help me, please?
If you use the xpath //ul[#class="gallery course-list"] you'll get all the licontaining courses.
If you want the link in each a element you should try this:
//ul[#class="gallery course-list"]//a/#href

Unable to locate the correct element using xpath

I am facing issue in selecting a particular drop down from the webpage.
I need to select the second highlighted div tag in the image above.
The xpath that I am trying to use is:
//div[#class='page-container']//table//div[#class='ui-multiselect-selected-container']
Kindly suggest how can I edit the xpath to select the second div tag.
I am new to xpaths and any help will be appreciated.
I think the below xpath should work to locate the second instance
(//div[#class='ui-multiselect-selected-container'])[2]
The second row has a tr class. When you use //div[#class='page-container']//table//div[#class='ui-multiselect-selected-container'] since your are referring to relative div(using //) it points to 1st element found by default.
I see that the tr element for the second multiselect has a class attribute, which makes unique
so, this will be //div[#class='page-container']//table//tr[#class='rowRelativeTo']//div[#class='ui-multiselect-selected-container']
You can also use the style elements which are unique:
//div[#class='page-container']//table//tr[#class='rowRelativeTo']//div[#style='float:right'] /div[#class='ui-multiselect-selected-container']

xpath next button hidden

i am using xpath to go to the next page (for scraping)
but eventualy the "next" button hides how can i make sure that xpath doesnt select "next" again...
now its:
//A[.='Next']
the LI has the display none attribute
//LI[.='Next']
i tried
//LI[.='Next'][not(contains(#style,'display:none'))]//A[.='Next']
but it did'nt work...
whats the best way to solve this...
I fixed it with
//LI[not(contains(#style,'display: none'))]/A[.='Next']

Resources