I have the following HTML code:
<input type="submit" value="Publish" class="button submit">
I have written xpath as below:
//input[#value='Publish']
//input[#class='button submit']
//input[#type='submit']
What is the corresponding cssSelector for the above xpath for using in Selenium RC or WebDriver test?
xpath cssSelector
//input[#value='Publish'] input[value=Publish]
//input[#class='button submit'] input.button.submit
//input[#type='submit'] input[type=submit]
in order to select your input element you have to write somthing like this
input[type=submit] {
color: red;
}
the syntax is quite similar to xpath
input[att=val] - Match when the element's "att" attribute value is exactly "val"
Related
<a href="http://link.com">
<div style="background-image:url(https://imageurl.jpeg);">
</div>
</a>
Is there a selector in xpath that allows for getting the value of a certain css declaration, bearing in mind that it is an inline style.
In the code example above I want to retrieve the value of the "background-image" prop.
You could use the xpath :
substring-before(substring-after(//div/#style, 'background-image:url('), ')')
I want to create XPath as //a[class='btn btn-invisible btn-link routeLink'] and //a[data-route='#Leads'].
Other example: //div[#class='btn-group'] and //a[#text()='Leads']
HTML:
<div class="btn-group" style="display: none;">
<a class="btn btn-invisible btn-link routeLink" data-route="#Leads" href="#Leads">Leads</a>
//a[#class='btn btn-invisble' and data-route='#Leads']
In the second example: Do you want a div or do you want an anchor? Shouldn't those be different locators?
You can or them as such using a pipe: //div[#class='x']|//a[#text='aa'].
I think below is what you need:
1) //a[#class='btn btn-invisible btn-link routeLink'][#data-route='#Leads']
2) //div[#class='btn-group'][text()='Leads']
and if you really need to use 'and' then niharika_neo's suggestion should work too.
Below is the html code ..
<iframe id="I0_1366100881331" frameborder="0" width="100%">
<div class="ZRa">
<span id="button" class="hAa Qo Bg" tabindex="0" role="button" title="" aria- label="Click here to publicly +1 this." aria-pressed="false">
</div>
</iframe>
In the above scenario, I want to switch into the IFRAME (iframe id="I0_1366100881331") to perform some actions on the SPAN present in that IFRAME. I have tried with most of the cases but no result :(... any one please help.
I want the solution for cucumber using capybara ruby only..
Note: I tried with following code but no result.
page.driver.browser.switch_to.frame "I0_1366100881331"
within_frame(find('<css rule>')) do
<code for dealing with iframe entries>
end
I think you can try to use method:
within_frame 'id' do
<code for dealing with iframe entries>
end
Can have this code:
withinframe((:xpath,"//div")) do
#code
end
Can anyone advise how I can find this element by name using xpath?
<button style="position: relative; width: 69px;" type="button" class="x-btn-text " tabindex="0">Search</button>
You can use: //button[text()='Search']
//button/text() should return you "Search".
In RapidMiner, I'm trying to pull data from div class "description". When I test the syntax using Google XPath import XML, it returns the appropriate data. When I try the following in RapidMiner, I get blank results:
//h:div[#id='description']/text()
This works:
//h:div[#id='description']
but I get all of the HTML markup data with it.
What do I need to add or remove?
On the same document, I was able to get this to return expected results:
//h:label[#id='desc']/text()
XML:
div id="description" class="longdesc" style=" padding-top: 0px; display: block;" xmlns:IDB="urn:ItemDataBinding">Description Text Here./div