java - XPath from Chrome not working on Microsoft Edge -


i've wrote script test website , i've taken xpath google chrome elements , wanted test on microsoft edge, whenever run it, org.openqa.selenium.remote.protocolhandshake createsession error. guess it's not able find element on edge.

public class testing {     extenthtmlreporter htmlreporter = new extenthtmlreporter("d:\\selenium\\test_report.html");     extentreports extent = new extentreports();     extenttest test;     javascriptexecutor jse;     webdriver driver;      @beforetest     public void setup()     {         system.setproperty("webdriver.edge.driver", "d:\\selenium\\microsoftwebdriver.exe");          driver = new edgedriver();         driver.manage().window().maximize();         extent.attachreporter(htmlreporter);          jse = (javascriptexecutor)driver;         extent.setsysteminfo("browseer", "microsoft edge");         extent.setsysteminfo("os", "windows 10");          driver.get("https://www.hoteltreeoflife.com/reservation");      }     @test     public void test1()     {         test = extent.createtest("test case 1 : selecting dates", "clicking check availabiluty default dates");          test.info("finding check availability");         driver.findelement(by.xpath("/html/body/div[1]/div[3]/div[2]/div/div/form/div[4]/button")).click(); //<-- element         test.info("clicks on check availability");          string title = driver.gettitle();         assert.asserttrue(title.contains("choose room"));         test.info("successfully selected dates");     } }    

i couldn't find way xpath on edge.

edit:

this full error:

[testng] running:   command line suite  [verbosetestng] running: suite: "command line test" containing "1" tests (config: null) [verbosetestng] invoking configuration: "command line test" - @beforetest newpackage.testing.setup() [16:46:55.985] - listening on http://localhost:4848/  jul 26, 2017 4:46:57 pm org.openqa.selenium.remote.protocolhandshake createsession info: detected dialect: oss [verbosetestng] passed configuration: "command line test" - @beforetest newpackage.testing.setup() finished in 4794 ms [verbosetestng] invoking: "command line test" - newpackage.testing.test1() [verbosetestng] failed: "command line test" - newpackage.testing.test1() finished in 303 ms [verbosetestng] java.lang.assertionerror: expected [true] found [false] [verbosetestng]     @ newpackage.testing.test1(testing.java:53) [verbosetestng] invoking configuration: "command line test" - @aftermethod newpackage.testing.check(org.testng.itestresult)(value(s): [testresult name=test1 status=failure method=testing.test1()[pri:0, instance:newpackage.testing@59e84876] output={null}]) [verbosetestng] passed configuration: "command line test" - @aftermethod newpackage.testing.check(org.testng.itestresult)(value(s): [testresult name=test1 status=failure method=testing.test1()[pri:0, instance:newpackage.testing@59e84876] output={null}]) finished in 462 ms [verbosetestng] invoking configuration: "command line test" - @aftertest newpackage.testing.close() [16:47:03.511] - stopping server. [verbosetestng] passed configuration: "command line test" - @aftertest newpackage.testing.close() finished in 3788 ms [verbosetestng]  [verbosetestng] =============================================== [verbosetestng]     command line test [verbosetestng]     tests run: 1, failures: 1, skips: 0 [verbosetestng] ===============================================  =============================================== command line suite total tests run: 1, failures: 1, skips: 0 ===============================================  java result: 1 

here answer question:

to click on button check availability instead of absolute path used:

driver.findelement(by.xpath("/html/body/div[1]/div[3]/div[2]/div/div/form/div[4]/button")).click(); 

consider using following unique logical xpath:

driver.findelement(by.xpath("//button[@class='btn btn-primary btn-block']")).click(); 

let me know if answers question.


Comments

Popular posts from this blog

python - Selenium remoteWebDriver (& SauceLabs) Firefox moseMoveTo action exception -

html - How to custom Bootstrap grid height? -

transpose - Maple isnt executing function but prints function term -