selenium error after entering the header file web driver - selenium

[header files[][1]1seelnium webdriver
error
Exception in thread "main" java.lang.NoClassDefFoundError: org/openqa/selenium/support/ui/Select (wrong name: org/openqa/selenium/support/ui/select)
Code tried:-
Select select = new Select(driver.findElement(By.cssSelector("body > app-root > app-patient-index > app-patient-profile > div.s_detail_doc_wrapper > div.s_patient_detail_tab > div > tabset > div > tab.active.tab-pane > form > div > div.s_patient_profile_form > div > div.col-md-9 > ul > li:nth-child(2) > div > div.col-md-9 > div > div.col-sm-5.pl0 > select")));
select.deselectAll();
select.selectByVisibleText("Married");
enter image description here
enter image description here

Please use the below code to select the value from the dropdown.
Note: If the dropdown is of type select.
import to be used is.
import org.openqa.selenium.support.ui.Select;
System.setProperty("webdriver.chrome.driver","Drivers/chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.get("https://www.facebook.com/");
Thread.sleep(3000);
Select dayDropDown = new Select(driver.findElement(By.xpath("//select[#name='birthday_day']")));
dayDropDown.selectByVisibleText("5");

Missing Select class is found inside elenium-support jar which you are missing.
You can download jar directly for example for version 2.0a7 from :
http://central.maven.org/maven2/org/seleniumhq/selenium/selenium-support/2.0a7/selenium-support-2.0a7.jar
Or add maven dependencies
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-support -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-support</artifactId>
<version>2.0a7</version>
</dependency>

Related

findelement vba

I am trying to fill a webelement with Selenium but can't 'reach' it. This is the code I am going to use:
Dim driver As New webdriver
driver.Start "Chrome"
driver.get "https://example.com"
'driver.FindElementByClass("gn_sdm_header_background").FindElementByName("searchKey").SendKeys ("abcd")
'driver.FindElementByCss("#gobtnDiv > form > table > tbody > tr > td:nth-child(3) > input[type=text]").SendKeys ("abcd")
'driver.FindElementByXPath("//*[#id=""gobtnDiv""]/form/table/tbody/tr/td[3]/input").SendKeys ("abcd")
End Sub
All the lines above resulted NoSuchElementError
Element not found for...
line: class=gn_sdm_header_background
line: Css= #gobtnDiv > form > table > tbody > tr > td:nth-child(3) > input[type=text]
line: XPath=//*[#id="gobtnDiv"]/form/table/tbody/tr/td[3]/input
And here are the parameters of the field:
Printscreen of element-inspection
I have no idea how to do it, so any help is greatly appreciated!!
The input element is inside an iframe. you need to switch to iframe first, in order to access the input element.
driver.SwitchToFrame .FindElementByXPath("//iframe[#name='gobtn']", timeout:=10000)
driver.FindElementByXPath("//input[#name='searchKey']").SendKeys ("Test")

How to send text into br element using Selenium

I am trying to make a tiktok bot, but I am having issues entering in text to their caption section(see screenshot below). I've tried using wait till element clickable function, but for some reason I can not use selenium to detect this element, would anyone have any suggestions on how to go about this, thank you in advance :)
My current code is below:
driver.get("https://www.tiktok.com/upload?lang=en")
try:
element = WebDriverWait(driver, waittime).until(EC.element_to_be_clickable((By.CSS_SELECTOR, '#root > div > div > div > div > div.jsx-410242825.contents-v2 > div.jsx-2580397738.form-v2 > div.jsx-2580397738.caption-wrap-v2 > div > div:nth-child(1) > div.jsx-1717967343.margin-t-4 > div > div.jsx-1043401508.jsx-723559856.jsx-1657608162.jsx-3887553297.icon-style.hash')))
except:
driver.quit()
element.click()
try:
element = WebDriverWait(driver, waittime).until(EC.presence_of_element_located((By.CSS_SELECTOR, '#root > div > div > div > div > div.jsx-410242825.contents-v2 > div.jsx-2580397738.form-v2 > div.jsx-2580397738.caption-wrap-v2 > div > div:nth-child(1) > div.jsx-1717967343.margin-t-4 > div > div.jsx-1043401508.jsx-723559856.jsx-1657608162.jsx-3887553297.editor > div > div > div > div > div > div > span > span > span')))
except:
driver.quit()
element.clear()
element.send_keys(mainCaption)
Element snapshot:
HTML <br> Tag
The <br> tag inserts a single line break. The <br> tag is an empty tag which means that it has no end tag and is useful for writing addresses or poems to enter line breaks, not to add space between paragraphs. Hence, you can't send any text within a <br> element.
Presumably, <br> tags will have parent/ancestor <p> tags. As an example:
<p>Be not afraid of greatness.<br>
Some are born great,<br>
some achieve greatness,<br>
and others have greatness thrust upon them.</p>
<p><em>-William Shakespeare</em></p>
So in these cases you need to target the parent/ancestor <p> tags to send the text.

Get Text from strange <i> tag in selenium

I want to get text (_reserve0|uint112 : 80540710293008523149) from these tags . check image.
Image
I'm getting only the first text value (_reserve0|uint112).
My code:
reserve_unit0 = driver.find_element_by_xpath("//*[#id='readCollapse8']/div/form/div/i[4]")
print(reserve_unit0.text)
I tried this code but still, I get only "_reserve0|uint112"
print(driver.execute_script('return arguments[0].lastChild.textContent;', WebDriverWait(driver, 20).until(
EC.visibility_of_element_located((By.CSS_SELECTOR, "#readCollapse8 > div > form > div > i:nth-child(8)")))).strip())

What are the steps involved for svg button click and copy the url

Writing steps for UI testing using karate framework
so basically svg button, have to click then the URL in the new tab for further functionality processing
how to handle that ?
i tried below code
def secure_url = mouse("#root > section > section > main > div > div > div.ant-table-wrapper > div > div > div > div > div > table > tbody > tr:nth-child(1) > td:nth-child(7) > span > button > svg").click()
and verified the secure_url value using
print secure_url
it prints com.intuit.karate.driver.DriverMouse#664e5dee
but Expected is URL
Most Karate methods will return an Element object on which you have to call more methods. Please spend some time to read the docs: https://github.com/intuit/karate/tree/master/karate-core#chaining
* def elem = locate('#some-id')
* def url = elem.attribute('href')

Link not working when clicked by Testcafe inside iframe

I am trying to sett upp some simple verification in our demoshop.
It works until clicking the "genomför köp" (make purchases) link is clicked.
The link markes as clicked (color change) but the proper actions are not performedand you stay on the same side.
if you add a debugline after the "await t.click('#purchase-button');" line you can click the link manualy, you can hover over the link so testcafe finds it. But for some reason tha click() dont work.
EDIT:1: the OS i am using is WIn10, running testcafe 1.8.2 under phpstorm 2019.3.3 and calling it with "testcafe chrome *.js"
Any help would be appreciated.
/Christoffer
Relevant code is below and the demoshop is open to use.
fixture`demoshop.resurs.com`
.page(https://demoshop.resurs.com);
test(
'Run: demoshop.resurs.com', async t => {
await t
.click('.home-shop-now')
.click('#root > div > main > div > div.container > div.products-container.mb-60 > div:nth-child(1) > a > img')
.click('#root > div > main > div > div > div.product-detail__container > div.product-detail__info-container > div.product-detail__add-to-cart > div > button')
.click('#root > div > main > div > span > header > div > div > div > span.shopping-bag-icon.clickable > div')
.click('#root > div > main > div > span > div > div > div > div.shopping-cart-container > a');
await t.switchToIframe('iframe');
await t.click('#purchase-button'); //This does not work properly
await t.expect(Selector('h2').innerText).contains('Tack för din order!');
}
);
I was able to reproduce the issue with TestCafe#1.8.2 but the test works as expected with TestCafe#1.8.4.
I recommend you update to the latest TestCafe version and apply changes provided by #DmitryOstashev:
import { Selector } from 'testcafe';
fixture`demoshop.resurs.com`
.page('https://demoshop.resurs.com');
test(
'Run: demoshop.resurs.com', async t => {
await t
.click('.home-shop-now')
.click('#root > div > main > div > div.container > div.products-container.mb-60 > div:nth-child(1) > a > img')
.click('#root > div > main > div > div > div.product-detail__container > div.product-detail__info-container > div.product-detail__add-to-cart > div > button')
.click('#root > div > main > div > span > header > div > div > div > span.shopping-bag-icon.clickable > div')
.click('#root > div > main > div > span > div > div > div > div.shopping-cart-container > a');
await t.switchToIframe('iframe');
await t.click('#purchase-button');
await t.switchToMainWindow();
await t.expect(Selector('h2').innerText).contains('Tack för din order!');
}
);