How to group with Emmet - emmet

div>header>ul>li*2>a+footer>p is not working for me. I need to group whatever is between the ul and a. How can I do this?

You can group things with Emmet with the brackets.
In your case: div>header>(ul>li*2>a)+footer>p
Give it a try.

Related

How to find an xpath of element?

I am trying to find the xpath of svg next to
"//label[#class='btn btn-light p-1']/input[#value='star']
https://9qrcode.com/#link
then select Design
I hate to do such xpaths, since I agree with Eliyahu - these kind of xpaths won't be unique...but since you asked, here you go, this should work for you:
//input[#value = 'star']/parent::label[contains(#class, 'btn-light')]/preceding-sibling::label[contains(#class, 'btn-light')]/*[name() = 'svg']
You can use this xpath -
(//label[contains(#class,"btn btn-light")]/*[local-name() = 'svg'])[2]
your can put your element number in replacing [2].
//input[#value='star']/preceding::label[#class='btn btn-light p-1'][1]
This will get the preceding element before the value of star which since it's not unique will give two values.

How to validate a text in selenium where multiple spaces in between two words?

I would like to know how to write the Xpath for validate the text -'Confirm Passowrd*' where there is more than 10 space gap between two words
When I tried to get it using chropath tool it gives Xpath like
//label[contains(text(),'Confirm Password*')]
But even that is also not working.
you can use the normalize-space in xpath.
//label[#ng-if='add_user' and normalize-space(text())='Confirm Password*']
You can also get text by:
driver.findElement(By.xpath("//label[#ng-if='add_user']")).GetAttribute("innerText");
OR
driver.findElement(By.xpath("//label[#ng-if='add_user']")).GetAttribute("value");
driver.findElement(By.xpath("//label").GetAttribute("value");

xpath=(//a[contains(text(),'-PPxo-P24-FA')])[2] fails to select

This is what I have
1000000 Venelin-PPxo-P24-FAID-EUR
want to write an XPath for the a based on its contained text. I tried the below but it does not work
xpath=(//a[contains(text(),'-PPxo-P24-FA')])[2]
However, if I try with the below, it works
xpath=(//a[contains(text(),'-PPxo-P24-FAI')])[2]
I am using Selenium IDE 2.9.1 if that makes any contribution to my question.
Hi it seems your Xpath is incorrect
can you try following:
xpath = ("//a[contains(text(),'-PPxo-P24-FA')][2]")
Thank you for all of the answers, guys!
However, I found the solution. It looks like the website contains the text some more times than I need it to. The working code is:
xpath=(//a[contains(text(),'-P24-')])[6]

How to write xpath for the on/off button present in a table for which class is compound class

This element can be turned off or on. As the class is compound class, not sure how to write the xpath. So wrote like this
//tr[1]/td[4]/div[1]/div/div/div[#css='div.ios-switch.on']
Screen shots are attached here
Can you help me in writing the xpath for this element
Use this instead - //tr[1]/td[4]/div[1]/div/div/div[#class='ios-switch on']
"#checkbox1011 [class^='ios-switch']"
or
"#checkbox1011 .ios-switch.on,.ios-switch.off"
Try using these CSS selectors.
//div[#id='checkbox1011']//td[#class='ios-switch-on']
Try:
//tr[1]/td[4]/div[1]/div/div/div[#css='.ios-switch.on' or '.ios-switch.off']
Hopefully this should work.
For the above screenshot, let me assume the username as sabrina galloway.
The toggle switch should present in the same row of username column.
You can use xpath like,
.//tr[./descendant::td[contains(.,'sabrina galloy')]/descendant::*[contains(#class,'ios-switch')]/div[#class='handle']
Use //div[starts-with(#class,'ios-switch')]

Xpath for href element

I need to click on the below href element,which is present among similar href elements.
<a id="oldcontent" href="listDetails.do?camp=1865"><u>Re-Call</u></a>
Can anyone provide me xpath to click the above href link?
Try below locator.
selenium.click("css=a[href*='listDetails.do'][id='oldcontent']");
or
selenium.click("xpath=//a[contains(#href,'listDetails.do') and #id='oldcontent']");
This works properly try this code-
selenium.click("xpath=//a[contains(#href,'listDetails.do') and #id='oldcontent']");
This will get you the generic link:
selenium.FindElement(By.XPath("xpath=//a[contains(#href,'listDetails.do')")).Click();
If you want to have it specify a parameter then you will have to test for each one:
...
int i = 1;
selenium.FindElement(By.XPath("xpath=//a[contains(#href,'listDetails.do?camp=" + i.ToString() + "')")).Click();
...
The above could utilize a for loop which navigates to and from each camp numbers' page, which could verify a static list of camps.
Please excuse if the code is not perfect, I have not tested myself.
have you tried:
//a[#id='oldcontent']/u[text()='Re-Call']
for me worked //a[text()='Re-Call']
what worked for me:
//a[contains(#href,'logout')]
Below works fine.
//a[#id='oldcontent']
If you've tried certain ones and they haven't worked, then let us know, otherwise something simple like this should work.
Best way to locate anchor elements is to use link=Re-Call:
selenium.click("link=Re-Call");
It will work..