I created my own customized xpath for the following steps to LinkedIn:
www.linkedin.com - Launch the URL
Sign in
View Profile
Click on Jobs
Type in QA Lead
Click on Date Posted
Select within 24hrs
Click on Apply <------ Here where I am not able to click on this button.
Xpath:
driver.findElement(By.xpath("button[#class='facet-collection-list__cancel-button mr2 artdeco-button artdeco-button--muted artdeco-button--2 artdeco-button--tertiary ember-view']//span[text()='Cancel']/parent::button/following-sibling::button//span[#class='artdeco-button__text']")).click();
enter image description here
You need to identify the expanded section first, then some unique attribute of the button, example:
Xpath: //form[#aria-expanded='true']//button[#data-control-name='filter_pill_apply']
css: form[aria-expanded=true] button[class*=apply]
I was able to figure it out. I modified the xpath accordingly and it worked:
driver.findElement(By.xpath("//*[#data-control-name='filter_pill_cancel' and #class='facet-collection-list__cancel-button mr2 artdeco-button artdeco-button--muted artdeco-button--2 artdeco-button--tertiary ember-view']//span[#class='artdeco-button__text' and text()='Cancel']/parent::button/following-sibling::button//span[text()='Apply']")).click();
Related
I am using Cypress to click a link on the Homepage which opens the respective page in the new window. I am not able to identify any element on this page. I am doing this to verify that the click opens the correct page.
I saw the link: Access a new window - cypress.io which didn't help much to answer the problem.
Please suggest if there is some way to test this.
I have tried few things like:
cy.window().contains('.div.trItem')
cy.window().its('.trValue).should('eq','SomeHeading')
cy.url().should('include', '/theLink1.html/')
Expected:
- Clicking link open the correct page in new window
- Identify URL in new window includes some text
- Certain text displays on the new window
First of all, you can't access to another tab or window with Cypress. Consider to separate your test cases. For example, in one test you could check that a element contains href attribute with expected url and target attribute with _blank.
Like this:
it('contains valid a element', () => {
cy.visit('https://example.cypress.io/')
cy.contains('Cypress.io').should('have.attr', 'href', 'https://www.cypress.io').should('have.attr', 'target', '_blank')
})
And in second test check that your other page contains expected text.
This one is bugging me. The same xpath is waited for and found. Then i attempt to click it and get an error. Code as below
Wait Until Element Is visible xpath=//*[#id="content"]/div[1]/div/div/div[2]/div[1]/div/h3/a/i[1]
Click Link xpath=//*[#id="content"]/div[1]/div/div/div[2]/div[1]/div/h3/a/i[1]
Error here
ValueError: Element locator 'xpath=//*[#id="content"]/div[1]/div/div/div[2]/div[1]/div/h3/a/i[1]' did not match any elements.
I know for sure by going in manually that the xpath is there. Something funny about the way Robot does this perhaps?
Click link will actually look for a link attribute (a=) but your locator is not an 'a' attribute.
Try 'Click Element' instead of 'Click Link'
I Want to find out xpath of login button from attached screenshots.
I have tried
Wait Until Page Contains Element xpath=//android.view.View[#content-desc='Login']
This return successful for finding element
but it does not click with below line of code
Click Element xpath=//android.view.View[#content-desc='Login']
Maybe you need to check if element is available, for example with:
Wait Until Element Is Visible xpath=//android.view.View[#content-desc='Login']
Or
Wait Until Element Is Enabled xpath=//android.view.View[#content-desc='Login']
I have attached screenshot after performing above steps.please check...
I am trying to automate actions and unable to select an element due to its dynamic nature.
I am running Selenium web driver on ruby and am trying to select value that is not present in page source.
<a class="linkOtherBrowser" onclick="addChangeStatusField('InitialSelectionPage');submitFormByAction('ChangeStep');return false;" href="#"><div class="processBarElement noSelected">
<div class="whiteBeforeProcessBarTitles"></div>Initial Selection</div>
<div class="endOfElementOfProcessBar"></div></a>
I am trying to select value "Initial Selection" from above.
Could anyone pls help out?
Thanks,
Abhishek
As the HTML is generated by Javascript, You need to inspect the DOM instead of viewsource and write the element locator code accordingly.
Note: In IE, Firefox or Chrome you can press F12 key to see the developer tools and use the inspect element option to check the DOM.
Whatever element is generated dynamically is added in your DOM. WebDriver has capability of clicking on elements are the visible on UI and hence if the generated element is visible to regular user's you can click on the element easily.
To do so, you need to identify the best selector for that newly generated click, could be xpath or css. Once you identify the selector you can consider clicking clicking using following code
WebElement element = driver.findElement(By.xpath("//a[#title='NAME_TITLE']"));
element.click();
OR
WebElement element = driver.findElement(By.css("a[title='NAME_TITLE']"));
element.click();
There are more options within your By.class on picking the element in best way
I am trying to retrieve, modify, and reinsert some text in a pop up dialog using watir web-driver. All was going swimmingly until I tried to find a way to click the "Save Book Info" button pictured here: http://i.stack.imgur.com/pGdln.png
However I am unable to find the button. To access the pop up box I gather all the links with the correct name into an array:
#browser.imgs.each do |img| #The links are imgs
if img.title.include?('Edit/Delete Book')
#books << img
end
end
From there I can access the links with #books[index].click. I am able to access and edit the text_fields with:
url = #browser.text_field(:name=>'url').value
... do stuff with url ..
#browser.text_field(:name=>'url').set url
But when I try and find the "Close" button I only get the buttons that are on the main page. After many headaches I managed to find the title of the window I want to work with using #browser.div(:class=>'dijitDialogTitleBar').title, which returns "Edit Book". Success! No. I still can't figure out how to access the buttons on that popup!
If anyone could help me with this I would be most grateful. This is my first time using Watir so it's probably a simple answer...
If more information is needed I'd be happy to supply it. Thanks in advance.
EDIT
Here is the html for the button:
<span id="dijit_form_Button_2_label"
class="dijitReset dijitInline dijitButtonText"
dojoattachpoint="containerNode">Save Book Info</span>
It looks like you have a span tag that is styled to be looked like a button. You need to access it is a span instead of a button.
Try:
#browser.span(:text => 'Save Book Info').click